Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save valentinvichnal/46cf6e74220bedde00e3f37f654e83fe to your computer and use it in GitHub Desktop.
Save valentinvichnal/46cf6e74220bedde00e3f37f654e83fe 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