我注意到,fail2bans iptables规则只适用于*新的连接意味着只要有人继续锤击login(基本身份validation或WordPress的等现有的连接继续允许它。
如果我暂停几秒钟,则cloudflare防火墙会阻止访问。
nginxlogging正确的IP,fail2ban报告他正确的ip被禁止,cloudflare也正确地添加了防火墙规则,显示ip地址。
我试过在ip上使用tcpkill,但是什么都不做。 我猜实际的连接是与cloudflare,这使得cloudflare和iptables在连接可以重用的地方是无用的。 build议? 大概一些应用程序层阻塞? nginx基本身份validation不会比较可怕。
因此,所有这一切都会阻止实际用户,而不采取任何措施防止暴力攻击。 希望我错过了一些东西。
Fail2Ban本质上是通过拖拽networking服务器的日志文件来实现的。 为了使Fail2Ban能够与CloudFlare一起高效工作,您的日志文件将需要logging原始的访问者IP而不是CloudFlare的。
有一个关于如何做这个标题为“ 如何使用Nginx恢复原始访问者IP? ”的指南,但其基本原理如下:
首先在Nginx上安装ngx_http_realip_module ,你可以通过安装带有--with-http_realip_module参数--with-http_realip_module 。
下一步是将以下内容添加到您的Nginxconfiguration中:
set_real_ip_from 103.21.244.0/22; set_real_ip_from 103.22.200.0/22; set_real_ip_from 103.31.4.0/22; set_real_ip_from 104.16.0.0/12; set_real_ip_from 108.162.192.0/18; set_real_ip_from 131.0.72.0/22; set_real_ip_from 141.101.64.0/18; set_real_ip_from 162.158.0.0/15; set_real_ip_from 172.64.0.0/13; set_real_ip_from 173.245.48.0/20; set_real_ip_from 188.114.96.0/20; set_real_ip_from 190.93.240.0/20; set_real_ip_from 197.234.240.0/22; set_real_ip_from 198.41.128.0/17; set_real_ip_from 199.27.128.0/21; set_real_ip_from 2400:cb00::/32; set_real_ip_from 2606:4700::/32; set_real_ip_from 2803:f800::/32; set_real_ip_from 2405:b500::/32; set_real_ip_from 2405:8100::/32; set_real_ip_from 2c0f:f248::/32 set_real_ip_from 2a06:98c0::/29 # use any of the following two real_ip_header CF-Connecting-IP; #real_ip_header X-Forwarded-For;