secret
Created

  • Download Gist
gistfile1.nginxconf
Nginx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
http {
limit_req_zone $binary_remote_addr zone=STATIC_LIMIT_REQ:1m rate=50r/s;
limit_req_zone $binary_remote_addr zone=DYNAMIC_LIMIT_REQ:1m rate=5r/s;
 
# set up "global" limit_req for all requests, including static files:
limit_req zone=STATIC_LIMIT_REQ burst=100 nodelay;
 
server {
server_name mydomain.com;
location /admin {
# This works fine!
limit_req zone=DYNAMIC_LIMIT_REQ burst=5 nodelay;
 
# ...
proxy_pass http://admin;
}
 
location / {
# try for page-cached files, so don't want to rate limit here:
try_files /maintenance.html $cache_path @dynamic;
}
 
location @dynamic {
# Here all requests will be passed to our backend servers, so we want to limit but...
# This limit_req is ignored!
limit_req zone=DYNAMIC_LIMIT_REQ burst=5 nodelay;
 
# ...
proxy_pass http://backend;
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.