Skip to content
Create a gist now

Instantly share code, notes, and snippets.

anonymous /gist:bf347d5302b3463f970b secret
Created Sep 24, 2013

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 {
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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.