用了cdn,想获取用户的真实ip,这样配置nginx.conf
在http模块中添加如下代码:
set_real_ip_from 0.0.0.0/0;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
或者把0.0.0.0/0替换为cdn的ip段【太麻烦】
如果用appnode,在 网站设置-基本-真实ip识别,相应的ip设置为0.0.0.0/0
重启nginx
据说设置为0.0.0.0/0不太安全,不知道具体如何?请高手指点。
除了这2种有没有更好的方法?