Fail2ban: regex test succeed but fail2ban does not ban any IP

fail2banregex

I can't ban any ip, thought when I test my regex, it has +2000matches:

> fail2ban-regex '/var/log/nginx/access.log' '/etc/fail2ban/filter.d/bad-request.conf'
Date template hits:
|- [# of hits] date format
|  [1172344] Day(?P<_sep>[-/])MON(?P=_sep)Year[ :]?        24hour:Minute:Second(?:\.Microseconds)?(?: Zone offset)?
Lines: 1172344 lines, 0 ignored, 2198 matched, 1170146 missed [processed in 223.96 sec]  

Here is my failregex:

^<HOST> -.*GET.*(\.php|\.asp|\.exe|\.pl|\.cgi|\scgi)

i am using 0.9. version.

Log files looks like this:

1.39.61.27,151.249.92.71,118.186.70.18,118.186.70.8,192.168.99.251,118.186.70.181,118.186.70.17,118.186.70.112,118.186.70.18,118.186.70.18,192.168.99.251 - "OPTIONS /js/shs/json HTTP/1.1" - [09/Oct/2015:15:33:29 +0800] 200 508 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/43.0.2357.130 Chrome/43.0.2357.130 Safari/537.36" "-"
- - "GET /wp-login.php HTTP/1.1" - [09/Oct/2015:15:33:30 +0800] 200 130761 "-" "-" "-"

I checked iptables -L, output is just normal, no banned IP:

Is it log date format not complying with fail2ban standards? Where should I check next?

Best Answer

I got it working finally, my mistake was to set action to :

action = %(action_mwl)s

inside jail.local when I didn't have mail server. I adjusted action to

action = %(action_)s

the default one, and i am now blocking many malicious traffics automatically with fail2ban. Next step would be permanently block them. cheers.