Rate limiting config block
Limit to 10 req/s per IP with burst of 20 (add to http/server block)
limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;
limit_req zone=api burst=20 nodelay;
- tool
- nginx15 commands
More nginx commands
-
upstream backend { server 10.0.0.1:8080; server 10.0.0.2:8080 backup; keepalive 32; }Round-robin upstream with backup and keepalive connections
-
gzip on; gzip_types text/plain text/css application/json application/javascript; gzip_min_length 1024; gzip_comp_level 6;Compress text responses ≥1KB at level 6
-
error_page 429 /429.json; location = /429.json { default_type application/json; return 429 '{"error":"rate_limited"}'; }Custom JSON body for rate-limit or error responses
-
server { listen 80; return 301 https://$host$request_uri; }Permanent redirect all HTTP traffic to HTTPS
-
curl -s http://localhost/stub_statusBuilt-in nginx status page: active, reading, writing, waiting