Folks...I asked this question on the StackExchange site and it was suggested that here would be better...
I have an nginx website which is getting lots of hits for a non-existent file "mydata.html". These hits are recorded in the site's access log with 301 (or 302) status codes. I'd like to know how to configure a Fail2ban jail which will catch these hits and ban the IP if they are excessive.
Here is an example record from the log file:
1.2.3.4 - - [02/Mar/2025:00:00:06 -0700] "GET /MyData.html HTTP/1.1" 301 185 "http://xxx.MySite.com/MyData.html" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36"
And my attempt at a regex to select the entry ^.*MyData.*HTTP.* 301. Can that regex be modified to also get the 302 or other codes?
Can someone offer some guidance, I'm worse than a beginner with regex expressions. Thanks....RDK