I'm trying to get fail2ban to block IPs that mod_security blocks three times. However, fail2ban is instead blocking anything which simply shows up in the mod_security log three times.
This is all running on Apache2, the latest modsecurity with the CRS in anomaly blocking mode, and the latest fail2ban.
Fail2ban was configured for modsecurity according to this page.
This is in my httpd.conf:
<IfModule security2_module>
SecAuditEngine RelevantOnly
SecAuditLog logs/modsecurity_audit.log
SecAuditLogType Serial
SecAuditLogRelevantStatus "^(?:5|4(?!04))"
SecDebugLog logs/modsecurity_debug.log
SecDebugLogLevel 0
SecDataDir logs/modsecurity_data
SecTmpDir /tmp
SecRequestBodyAccess On
SecResponseBodyAccess On
Include conf/modsecurity_crs/*.conf
Include conf/modsecurity_crs/activated_rules/*.conf
</IfModule>
Is it possible to get modsecurity to only log what it has blocked? If not, is there a way to get modsecurity to use a custom log format so that I can write a new failregex for fail2ban to only pick up what I want? i.e. there is no single line in the audit log which has both the host ip and the return status; if that were the case I could write a failregex to block what I want.