33
loading...
This website collects cookies to deliver better user experience
access.log
to detect if an IP generates too many 404 errors within a specified period of time. If an IP is caught breaking the rules, we'll put them in jail by temporarily banning them from accessing the server. nginx-4xx.conf
to /etc/fail2ban/filter.d/
[Definition]
failregex = ^<HOST>.*"(GET|POST).*" (404|444|403|400) .*$
ignoreregex =
/etc/fail2ban/jail.conf
and add the following block of code to the end of the file.[nginx-4xx]
enabled = true
port = http,https
filter = nginx-4xx
logpath = /var/log/nginx/access.log
bantime = 1800
findtime = 10
maxretry = 10
bantime
, maxretry
, and findtime
. This is saying if a user hits the 4xx error 10 times over a 10 second period, then ban the user's IP for 1800 seconds, which is 30 minutes. service fail2ban restart
fail2ban-client status nginx-4xx
fail2ban-client status nginx-4xx
to see that you have been jailed. 🚔