Se o nginx estiver atrás de um ELB, precisa checar o `http_x_forwaraded_proto` para nao ter problemas de `too many requests`
# Escopo: Dentro de um server {} / location {} / if {}
if ($http_x_forwarded_proto != 'https') {
rewrite ^ https://$host$request_uri? permanent;
}
# Escopo: dentro de um server {} / location {} / if {}
return 301 https://$server_name$request_uri;
https://easyengine.io/tutorials/nginx/log-parsing/
Com o log default do NGINX é possível usar Cat / Grep / CUT para recuperar umas informações ou até mesmo estatísticas!
To check your access by the HTTP code
cat stratus.access.log | cut -d '"' -f3 | cut -d ' ' -f2 | sort | uniq -c | sort -rn
Which URL generated your those 500 errors:
awk '($9 ~ /500/)' access.log | awk '{print $7}' | sort | uniq -c | sort -rn
Check how many times each IP hit your app:
awk '{print $1}' access.log | sort | uniq -c | sort -nr
Check the full log of those 500 requests:
grep -E '" 5[0-9]{2}' access.log