Top 10 requested URLs nginx
Most popular request paths from access log
awk '{print $7}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head -10
more nginx
all 15 commands →
Top IPs by request count
awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head -10
Rate limiting config block
limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;
limit_req zone=api burst=20 nodelay;
Upstream health proxy pass
upstream backend {
server 10.0.0.1:8080;
server 10.0.0.2:8080 backup;
keepalive 32;
}
Enable gzip compression
gzip on;
gzip_types text/plain text/css application/json application/javascript;
gzip_min_length 1024;
gzip_comp_level 6;
Return JSON error response
error_page 429 /429.json;
location = /429.json {
default_type application/json;
return 429 '{"error":"rate_limited"}';
}