File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88 include mime.types;
99 default_type application/octet-stream;
1010
11- # Define a shared memory zone for rate limiting (keyed by client IP)
11+ # Rate limiting: 5 requests per second per IP
1212 limit_req_zone $binary_remote_addr zone=api_ratelimit:10m rate=5r/s;
1313 limit_req_status 429;
1414
@@ -19,15 +19,17 @@ http {
1919 server {
2020 listen ${SERVER_HTTP_PORT};
2121
22- # Optional: allow health checks or pre-flight OPTIONS through without limits
22+ # Health check path
2323 location = /healthz {
2424 return 200 'ok';
2525 add_header Content-Type text/plain;
2626 }
2727
2828 location / {
29- # Apply rate limiting
30- limit_req zone=api_ratelimit nodelay;
29+ # Apply rate limiting with burst buffer
30+ limit_req zone=api_ratelimit burst=10;
31+ # Optional: tell clients how long to wait (1s = 5r/s baseline)
32+ add_header Retry-After 1 always;
3133
3234 proxy_pass http://varnish_backend;
3335 proxy_set_header Host $host;
You can’t perform that action at this time.
0 commit comments