nginx 多级反向代理获取客户端真实IP

set_real_ip_from 10.0.0.0/8;
set_real_ip_from 192.168.0.0/16;
set_real_ip_from 172.16.0.0/12;
set_real_ip_from 100.0.0.0/8;
set_real_ip_from 127.0.0.1;
real_ip_header X-Forwarded-For;
real_ip_recursive on;

默认情况下 real_ip_recursive off; $remote_addr字段显示的是二级代理的IP

real_ip_recursive on; 这个是过滤掉set_real_ip_from中的可信IP,$remote_addr字段显示的是真实的客户端IP

原文地址:https://www.cnblogs.com/37yan/p/9802879.html