fail2ban apache 重复 401 请求

fail2ban apache repeated 401 requests

我想对我的站点进行 fail2ban 重复 401 错误

我的日志文件条目...

116.108.172.173 - - [28/Aug/2018:08:30:36 -0400] "GET / HTTP/1.1" 401 742

我在 fail2ban conf 的尝试

 [Definition]
 failregex = (?P<host>[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}) . . .+ .+ .+ .+ .+ 401 [0-9]+

它似乎不起作用,有什么想法吗?

保持你的正则表达式简单。

[Definition]
failregex = ^<HOST> .+\" 401 \d+ .*$

应该做这份工作

Fedora 27/CentOS/RHEL

etc > fail2ban > filter.d > some-new-filter.conf

:: 过滤掉 .cgi 和 404 请求的示例,同时阻止实际域以外的任何内容

:: 引荐来源网址:

[Definition]
failregex = ^<HOST>.*(\.cgi\?).*$
            ^<HOST>.+\/.+\/.+\/.*\"\s(404)\s.*$
            ^<HOST>.+\/.+\/.+\/.*(\"http:\/\/some\.info\/.+\")\s.*$

然后:等 > fail2ban > jail.conf

[some-new-filter]
port     = http,https
logpath  = %(apache_access_log)s
           %(apache_error_log)s
maxretry = 2

测试:

fail2ban-regex /var/log/httpd/error_log /etc/fail2ban/filter.d/some-new-filter.conf
fail2ban-regex /var/log/httpd/access_log /etc/fail2ban/filter.d/some-new-filter.conf

重启fail2ban