76 字
1 分钟
ngnix使用CDN后正确获取访客IP
2020-08-30
无标签

如果是使用一层cdn,那么在nginx的配置文件http{}字段中加入

    set_real_ip_from 0.0.0.0/0;
    real_ip_header X-Forwarded-For;

即可。

如果是使用了两层或以上cdn(使用了cdn和web防火墙也适用),那么在nginx的配置文件http{}字段中加入

    set_real_ip_from 0.0.0.0/0;
    real_ip_header X-Forwarded-For;
    real_ip_recursive on;

即可。

ngnix使用CDN后正确获取访客IP
https://xiyu.pro/posts/9/
作者
席宇
发布于
2020-08-30
许可协议
CC BY-NC-SA 4.0