解决宝塔Nginx使用CDN后无法获取用户真实IP (含LNMP)

发布于 / 折腾 / 0 条评论

修改nginx.conf配置文件

使用lnmp的服务器一般配置文件在:/usr/local/nginx/conf/nginx.conf
使用宝塔Nginx的服务器一般配置文件在 :/www/server/nginx/conf/nginx.conf

打开添加

log_format  main  '"$http_x_forwarded_for"-$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"'; 

log_format main 这里的main 需要在各个需要开启的站点配置文件里面加上

最后网站日志完美记录真实ip与cdn节点的ip

CAPTCHAis initialing...
Not Comment Found