Is there a way to stop a WP hacking bot with null user-agent with fail2ban? #676
Replies: 2 comments
-
Beta Was this translation helpful? Give feedback.
-
|
Cloudflare WAF in front is genuinely the cleanest path if you've got CF on the domain — your VPS never sees the traffic, no fail2ban cycles burned. But the fail2ban setup you're asking about is straightforward on top of the 403 your vhost rule is already producing. CloudPanel v2 writes per-site logs under grep -h "access_log" /etc/nginx/sites-enabled/*.conf | head -5Plug the resolved pattern into the jail's Filter — [Definition]
failregex = ^<HOST>\s.*"(GET|POST|HEAD)\s[^"]*"\s(403|503)\s
ignoreregex =Jail — append to [nginx-bad-ua]
enabled = true
port = http,https
filter = nginx-bad-ua
logpath = /home/*/logs/nginx/access.log
maxretry = 3
findtime = 600
bantime = 86400
Two things to watch:
|
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
Fail2ban is already installed. I hope there's some easy way I can create a rule for all my WP sites to ban the bot IP which is hitting random pages like hunting for old plugins or hacked files.
For now I've created a rule in vhost to send 403 to any request which comes with null user-agent, it works.
It'd be great if fail2ban can pick up the 403 and 503 codes and ban those IPs which continuously hit all my WP websites. Maybe a feature in CP UI to have something for this?
Beta Was this translation helpful? Give feedback.
All reactions