-
-
Save anonymous/bf347d5302b3463f970b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment