我尝试为 fail2ban 创建一个自己的过滤器来检测失败的 HTTP 身份验证尝试。它在使用 fail2ban-regex 进行测试时确实有效,但在运行环境中无效。
/etc/fail2ban/jail.local
...
[DEFAULT]
bantime = 600
...
[nginx-user-auth]
enabled = true
filter = nginx-user-auth
port = http,https
logpath = /var/log/nginx/error.log
backend = polling
maxretry = 6
...
/etc/fail2ban/filter.d/nginx-user-auth.conf
[Definition]
failregex = user .*? password mismatch, client: <HOST>
user .*? was not found in .*?, client: <HOST>
ignoreregex =
测试时:
root@debian:~# fail2ban-regex /var/log/nginx/error.log /etc/fail2ban/filter.d/nginx-user-auth.conf
...
Success, the total number of match is 54
...
它还向我显示了正确的 IP 和日期/时间。
但是监狱没有检测到一次失败的登录尝试:
root@debian:~# fail2ban-client status nginx-user-auth
Status for the jail: nginx-user-auth
|- filter
| |- File list: /var/log/nginx/error.log
| |- Currently failed: 0
| `- Total failed: 0
`- action
|- Currently banned: 0
| `- IP list:
`- Total banned: 0
其他监狱运行良好。而且我完全不知道我在哪里犯了错误。
提前致谢!