在多ip的情况下获取了错误的真实ip地址或者1panel没有对ipv6进行适配?

1.网站同时使用代理服务器与 Cloudflare

2.所以在上述情况下X-Forwarded-For会返回多个ip(先是代理服务器记录了Cloudflare访问源站的IP即CDN-IP,然后Cloudflare记录了用户真实IP即图中ipv6地址):如下图OpenResty日志

  1. 根据维基百科:https://en.wikipedia.org/wiki/X-Forwarded-For

The general format of the field is:

X-Forwarded-For: client, proxy1, proxy2[3]

where the value is a comma+space separated list of IP addresses, the left-most being the original client, and each successive proxy that passed the request adding the IP address where it received the request from. In this example, the request passed through proxy1, proxy2, and then proxy3 (not shown in the header). proxy3 appears as remote address of the request.

所以当前情况下真实IP应该为上述图中的ipv6地址,即经过代理服务器,会出现上述情况,取第一个才是真实IP

4.使用1panel的WAF或网站监控功能,记录有下图日志(全部为CDN-IP)

786da23aa6bd048f4ad6c32eda937a11

因为我没有条件测试纯ipv4情况,而我的家庭带宽默认ipv6优先,所以出现这种情况我不知是1panel在多ip的情况下获取了错误的真实ip地址或者1panel没有对ipv6进行适配?


需要在这配置一下 CDN

我配置了cdn的,依旧如此,不论是这三个的任何一个。

CF-Connecting-IP X-Forwarded-For real_ip_header;

网站设置和全局设置都改一下

好吧,居然要网站设置和全局设置都要开启,能不能再给个同时打开所有网站cdn功能的开关或者写一句提示语。