Last active
February 28, 2020 16:52
-
-
Save AysadKozanoglu/3f084d3d8688a97012d9c84c6067fb97 to your computer and use it in GitHub Desktop.
request flood protection rate limiting nginx
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
# 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