I'm running Arch with Nginx and fail2ban. I have added this to /etc/fail2ban/filter.d/nginx-dos.conf:
# /etc/fail2ban/filter.d/nginx-dos.conf
# Fail2Ban configuration file
#
# Generated on Fri Jun 08 12:09:15 EST 2012 by BeezNest
#
# Author: Yannick Warnir
#
# $Revision: 1 $
#
[Definition]
# Option: failregex
# Notes.: Regexp to catch a generic call from an IP address.
# Values: TEXT
#
failregex = ^<HOST> -.*"(GET|POST).*HTTP.*"$
# Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored.
# Values: TEXT
#
ignoreregex =
I then went to /etc/fail2ban/jail.conf and have added this:
[nginx-dos]
# Based on apache-badbots but a simple IP check (any IP requesting more than
# 240 pages in 60 seconds, or 4p/s average, is suspicious)
# Block for two full days.
# @author Yannick Warnier
enabled = true
port = http
filter = nginx-dos
logpath = /var/log/nginx/access.log
findtime = 60
bantime = 172800
maxretry = 1
action = iptables[name=HTTP, port=http, protocol=tcp]
When I run tail -f /var/log/fail2ban.log
and then spam downloads on my site, it does in fact return with:
2020-09-19 13:13:24,726 fail2ban.actions [551857]: WARNING [nginx-dos] 66.249.66.79 already banned
If I run iptables -L
it returns with:
REJECT all -- crawl-66-249-66-79.googlebot.com anywhere reject-with icmp-port-unreachable
In this case, it has blocked a google bot. However, I have gotten fail2ban to report my own IP as being banned, but I still have full access to the site. I do not know what I am missing here. Everything seems to add up just fine, but still no rejection. Could anybody please help me figure out what is going on? Thank you