Skip to content

Instantly share code, notes, and snippets.

@igortik
Last active June 30, 2017 18:42
Show Gist options
  • Save igortik/81c91424a6cf7f22b6e7541d96c91771 to your computer and use it in GitHub Desktop.
Save igortik/81c91424a6cf7f22b6e7541d96c91771 to your computer and use it in GitHub Desktop.
Nginx example with DDoS mitigation example (503 error trick)
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