Created
February 21, 2019 01:18
-
-
Save muresan/382c3ecc68125133dc7450c0c8a310c6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # limit the number of connections to 1 per second and allow to burst to 10 | |
| limit_req_zone $http_x_forwarded_for zone=application:10m rate=1r/s; # For Load Balanced environments | |
| #limit_req_zone $remote_addr zone=application:10m rate=1r/s; # For Single Instance environments | |
| limit_req zone=application burst=10 nodelay; | |
| limit_req_status 429; | |
| limit_conn_status 429; | |
| # pass real IP from client to NGINX | |
| real_ip_header X-Forwarded-For; | |
| set_real_ip_from 0.0.0.0/0; | |
| server { | |
| # set error page for HTTP code 429 | |
| error_page 429 @ratelimit; | |
| location @ratelimit { | |
| return 429 'Connection Limit Exceeded\n'; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you should consider adding a "resolver" param in the http block in case you want to use secure dns resolver with unbound.