Skip to content

Commit 45f6e6d

Browse files
committed
Burst buffer in nginx config
1 parent 11304bf commit 45f6e6d

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

platform/nginx-backend.conf.template

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ http {
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;

0 commit comments

Comments
 (0)