Fail2Ban for [apache-botsearch]

I’ve noticed the activities of some bad bots on my server in the last couple of weeks.

After doing some digging around and reading more about F2B, I added this to my jail.local file.

[apache-botsearch]
enabled = true
port = http,https
logpath = %(apache_error_log)s
maxretry = 2

After a few days, it does not seem to work, did I get the config wrong?

If you want the correct conf to add to jail.local it should look like this:

[apache-botsearch]
enabled  = true
filter   = apache-botsearch
action   = hestia[name=WEB]
logpath  = /var/log/apache2/domains/*.log
maxretry = 2

And restart fail2ban systemctl restart fail2ban or reload it fail2ban-client reload

Anyway, I doubt that filter will work, it won’t detect anything.

Could you please paste some of the logs you detected so I can see their format?

root@server:~# grep ' 404 ' /var/log/apache2/domains/domain.com.log | tail
34.24.229.227 - - [06/Nov/2026:14:01:11 +0000] "GET /key.json HTTP/1.1" 404 4653 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
34.24.229.227 - - [06/Nov/2026:14:01:11 +0000] "GET /keyfile.json HTTP/1.1" 404 4653 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
34.24.229.227 - - [06/Nov/2026:14:01:11 +0000] "GET /firebase-adminsdk.json HTTP/1.1" 404 4653 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
34.24.229.227 - - [06/Nov/2026:14:01:11 +0000] "GET /firebase-key.json HTTP/1.1" 404 4653 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
104.22.219.107 - - [06/Nov/2026:15:07:14 +0000] "GET /wp-admin/install.php?step=1 HTTP/1.1" 404 9639 "-" "http://domain.com/wp-admin/install.php?step=1"
172.71.164.74 - - [06/Nov/2026:17:15:13 +0000] "GET /wp-admin/install.php?step=1 HTTP/1.1" 404 9639 "-" "http://domain.com/wp-admin/install.php?step=1"
104.23.239.79 - - [06/Nov/2026:19:27:46 +0000] "GET /wp-admin/install.php?step=1 HTTP/1.1" 404 9639 "-" "http://domain.com/wp-admin/install.php?step=1"
221.178.143.70 - - [06/Nov/2026:20:59:31 +0000] "GET /favicon.ico HTTP/1.1" 404 9639 "-" "Dalvik/2.1.0 (Linux; U; Android 9.0; ZTE BA520 Build/MRA58K)"
104.23.217.167 - - [06/Nov/2026:21:36:35 +0000] "GET /wp-admin/install.php?step=1 HTTP/1.1" 404 9639 "-" "http://domain.com/wp-admin/install.php?step=1"
135.148.195.2 - - [06/Nov/2026:22:44:41 +0000] "GET /favicon.ico HTTP/1.1" 404 4653 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.2 Safari/605.1.15"
root@server:~#

Thanks, above is the log format.

You should create your own filter to handle those entries. Also, you should never ban IPs just because of a missing favicon. I can also see Cloudflare IPs in that log, so if you’re using Cloudflare for your domain and ban one of those IPs, you could end up blocking access for lots of users (including yourself).

Thanks! I don’t use Cloudflare, so it’d quite strange.