大哥:
1.你首先要找到你的被攻击日志,找到问题根源才能找防护的办法;
2.别重复发帖;在之前的帖子都告诉你方法了;
给你看Nginx 在 使用 CF 下获取用户真实IP的方式.
当服务器使用了CloudFlare的cdn后,无法获取客户端正确的ip地址,为了获取到真实的客户端ip,nginx要配置realip模块和指定CloudFlare的节点ip地址.
配置CloudFlare节点ip
vi /etc/nginx/nginx.conf //写在http区域里
ipv4:
set_real_ip_from 199.27.128.0/21;
set_real_ip_from 173.245.48.0/20;
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 141.101.64.0/18;
set_real_ip_from 108.162.192.0/18;
set_real_ip_from 190.93.240.0/20;
set_real_ip_from 188.114.96.0/20;
set_real_ip_from 197.234.240.0/22;
set_real_ip_from 198.41.128.0/17;
set_real_ip_from 162.158.0.0/15;
ipv6:
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;
real_ip_header CF-Connecting-IP;
检查是否有错误,如果没有错误就可以重启nginx了.
ps:
如果CloudFlare节点ip变更,大家可以去下面地址获取最新的节点ip.
https://www.cloudflare.com/ips