-
-
Save valentinvichnal/51f542ba13d35915e5186febf742428d to your computer and use it in GitHub Desktop.
Nginx example with DDoS mitigation example (503 error trick)
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
| server { | |
| # ... | |
| # files starting with .dot | |
| # | |
| location ~ /\. { | |
| deny all; | |
| } | |
| location = /favicon.ico { | |
| return 404; | |
| access_log off; | |
| log_not_found off; | |
| } | |
| # DDoS Mitigation | |
| # | |
| # look at nginx.conf for: limit_req_zone | |
| # http://nginx.org/en/docs/http/ngx_http_limit_req_module.html | |
| error_page 503 =429 @ipcheck; | |
| location @ipcheck { | |
| internal; | |
| fastcgi_pass 127.0.0.1:9000; | |
| fastcgi_param SCRIPT_FILENAME /var/www/ipcheck.php; | |
| include fastcgi_params; | |
| } | |
| # other errors | |
| # | |
| error_page 500 501 502 504 /_errors/5xx.html; | |
| location ^~ /_errors/ { | |
| internal; | |
| root /var/www/; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment