Thursday, June 8, 2023

How to block 404 attacks using fail2ban

Add the following new file named nginx-4xx.conf to /etc/fail2ban/filter.d/

[Definition] 
failregex = ^<HOST>.*"(GET|POST).*" (404|444|403|400) .*$ 
ignoreregex =

Now, open /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 = 60
maxretry = 5

Now, restart process by running following command:

service fail2ban restart

To view status, including jailed IPs, you can run the following command:

fail2ban-client status nginx-4xx

Subscribe

  • RSS Atom

ອອນລາຍ: 1 | ມື້ນີ້: 13 | ວານນີ້: 25 | ທິດນີ້: 93 | ເດືອນນີ້: 872 | ປີນີ້: 11832 | ລວມ: 78935