Fail2Ban通过配置文件定义监控规则。我们需要创建一个自定义的配置文件来监控 Nginx 日志。创建自定义配置文件 在 /etc/fail2ban/jail.d/ 目录下创建一个新的配置文件,例如 nginx.local:添加以下内容:nginx-http-auth: 监控 Nginx 的认证失败(如 401 错误)。nginx-bad-requests: 监控 Nginx 的恶意请求(如...
例如,nginx-http-auth.conf 文件可能包含以下内容: ini [Definition] failregex = no user/password was provided for basic authentication.*client: <HOST> user .* was not found in.*client: <HOST> ignoreregex = 其他过滤器文件(如 nginx-badbots.conf、nginx-noscript.conf 等)也使用...
同理,jail.local配置文件里的nginx-http-auth模块也有对应命名的filter文件,但里面的匹配规则和我们实际场景不相符。 在/etc/fail2ban/filter.d目录下新增一个nginx-auth.conf文件,写入如下规则: 代码语言:shell AI代码解释 [Definition]failregex=<HOST>-.*- .*HTTP/1.*401.*$ ignoreregex= 修改jail.local,...
vim nginx-http-auth.conf 这个规则是存在的,我们在规则中加一行配置,来过滤除了账号密码错误外,空白账号或者密码的错误: [Definition] failregex = ^ \[error\] \d+#\d+: \*\d+ user "\S+":? (password mismatch|was not found in ".*"), client: , server: \S+, request: "\S+ \S+ HTT...
默认配置:Fail2Ban默认保护SSH服务,监控/var/log/auth.log文件。 配置文件:/etc/fail2ban/jail.local [sshd] enabled = true 1. 2. 2.2 HTTP/HTTPS(Apache/Nginx) 保护Web服务器:防止暴力破解、扫描和DDoS攻击。 配置文件: [nginx-http-auth]
[nginx-http-auth] enabled = true filter = nginx-http-auth port = http,https logpath = /var/log/nginx/error.log . . . 这是Ubuntu fail2ban软件包中唯一包含的特定于Nginx的监狱。但是,我们可以创建自己的jails来添加其他功能。 我们可以创建一个[nginx-noscript]jail来禁止在网站上搜索脚本的客...
filter = nginx-http-auth action = iptables-multiport[name=nginx-http-auth,port="80,443"] logpath = /var/log/nginx/error.log lighttpd防规击规则 复制代码 代码如下: [suhosin] enabled = true filter = suhosin action = iptables-multiport[name=suhosin, port="http,https"] ...
fail2ban是 Linux 上的一个著名的开源入侵保护服务框架,它可以监控多个系统的日志文件(例如:/var/log/auth.log 或者 /var/log/secure)并根据检测到的任何可疑的行为自动触发不同的防御动作。事实上,fail2ban 在防御对SSH服务器的暴力密码破解上非常有用,同时它也可以通过监控web服务器的日志(如Nginx、Apache)从而...
nginx防攻击规则 [nginx-http-auth]enabled=truefilter=nginx-http-auth action=iptables-multiport[name=nginx-http-auth,port="80,443"]logpath=/var/log/nginx/error.log 1. 2. 3. 4. 5. lighttpd防规击规则 [suhosin]enabled=truefilter=suhosin ...
tcp -- anywhere anywhere tcp dpt:httpf2b-NoAuthFailures tcp -- anywhere anywhere tcp dpt:httpf2b-SSH tcp -- anywhere anywhere tcp dpt:sshf2b-php-url-open tcp -- anywhere anywhere tcp dpt:httpf2b-nginx-http-auth tcp -- anywhere anywhere multiport dports http,...