Skip to content

Instantly share code, notes, and snippets.

@kkroesch
Created October 16, 2023 11:06
Show Gist options
  • Save kkroesch/f73b6f8dfb8073776a966cab187807b0 to your computer and use it in GitHub Desktop.
Save kkroesch/f73b6f8dfb8073776a966cab187807b0 to your computer and use it in GitHub Desktop.
Fail2ban filter 404-requests (unsolicited pentests) for Nginx
# in /etc/fail2ban/jail.conf
# ...
[nginx-4xx]
enabled = true
port = http,https
filter = nginx-4xx
logpath = /var/log/nginx/access.log
bantime = 3600
findtime = 10
maxretry = 10
# ...
# /etc/fail2ban/filter.d/nginx-4xx.conf
[Definition]
failregex = ^<HOST>.*"(GET|POST).*" (404|444|403|400) .*$
ignoreregex =
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment