HaProxy + CloudFlare

我正在尝试使用DDoS保护规则(速率限制)来设置HaProxy。 不过,我认为HaProxy现在正在限制CloudFlare IP,而不是访问者/真实IP。 (注:我的网站本身很好,因为我已经修复了我的网站的PHP代码)我该如何解决?

我的/etc/haproxy/haproxy.cfg

global log 127.0.0.1 local0 notice maxconn 10000 user haproxy group haproxy defaults log global mode http option httplog option dontlognull retries 3 option redispatch timeout http-request 10s timeout connect 5000 timeout client 30s timesout server 5000 frontend domain bind *:80 stick-table type ip size 1m expire 10s store gpc0,http_req_rate(10s) tcp-request connection track-sc1 src tcp-request connection reject if { src_get_gpc0 gt 0 } default_backend nginx backend nginx mode http stats enable stats uri /HIDDEN stats realm Strictly\ Private stats auth USER:PASSWORD balance roundrobin option httpclose option httpchk HEAD / HTTP/1.1\r\nHost:domainhidden.eu acl abuse src_http_req_rate(domain) ge 100 acl flag_abuser src_inc_gpc0(domain) tcp-request content reject if abuse flag_abuser server web1 iphere1:80 check server web2 iphere2:80 check server web3 iphere3:80 check 

我已经在configuration中更改了域名,用户名和密码,否则人们可能进入我的网站统计:P(domainhidden.eu,USER:PASSWORD和'iphere')

您必须将您的IP从您的费率限制=)列入白名单。

https://www.cloudflare.com/ips

所以你的ACL会是这样的(不知道是否完全正确):

 acl rate_whitelist src -f /path/to/whitelist-ips acl abuse src_http_req_rate(domain) ge 100 acl flag_abuser src_inc_gpc0(domain) tcp-request content reject if abuse flag_abuser !rate_whitelist 

然后你的whitelist-ips文件将是IP的列表(我想,不知道格式是否正确):

 199.27.128.0/21 173.245.48.0/20 103.21.244.0/22 103.22.200.0/22 103.31.4.0/22 141.101.64.0/18 108.162.192.0/18 190.93.240.0/20 188.114.96.0/20 197.234.240.0/22 198.41.128.0/17 162.158.0.0/15 104.16.0.0/12