Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@AysadKozanoglu
Last active February 28, 2020 16:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save AysadKozanoglu/3f084d3d8688a97012d9c84c6067fb97 to your computer and use it in GitHub Desktop.
Save AysadKozanoglu/3f084d3d8688a97012d9c84c6067fb97 to your computer and use it in GitHub Desktop.
request flood protection rate limiting nginx
# To enable rate limiting simply add the following line to the top-level of your config file:
# 1 request / second
limit_req_zone $binary_remote_addr zone=login:10m rate=1r/s;
# Then apply it to a location by adding a rate limiting burst to your server block:
location /account/login/ {
# apply rate limiting
limit_req zone=login burst=5;
# boilerplate copied from location /
proxy_pass http://myapp;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment