Par*_*met 9 security nginx fail2ban
我正在使用 Fail2Ban 并根据需要对其进行了配置。这是从 nginx/error.log 读取日志,并根据有关 maxretry 和计时集的配置进行操作。问题是这是否可能根据状态代码有不同的规则?
例如,我想阻止任何人404 Status code在 5 分钟内获得 10 ,但阻止任何人获得 3 403 Status code。
任何帮助将不胜感激,提前致谢。
小智 16
您应该添加一个/etc/fail2ban/filter.d/具有相关名称的过滤器- 例如nginx-{403,404}.conf。
它们应该包含类似于以下几行的内容:
nginx-403.conf :
[Definition]
failregex = ^<HOST> -.*"(GET|POST|HEAD).*HTTP.*" 403
ignoreregex =
Run Code Online (Sandbox Code Playgroud)
nginx-404.conf :
[Definition]
failregex = ^<HOST> -.*"(GET|POST|HEAD).*HTTP.*" 404
ignoreregex =
Run Code Online (Sandbox Code Playgroud)
然后你应该从你的 jail.conf 或任何你的 conf 文件中调用它们:
对于 403 :
[nginx-403]
enabled = true
port = http,https
filter = nginx-403
logpath = /var/log/nginx/access.log
maxretry = 5
findtime = 300
Run Code Online (Sandbox Code Playgroud)
而对于 404 :
[nginx-404]
enabled = true
port = http,https
filter = nginx-404
logpath = /var/log/nginx/access.log
maxretry = 10
findtime = 300
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8839 次 |
| 最近记录: |