nginx + varnish + nginx 获取客户端地址
nginx
http {
...
set_real_ip_from 153.37.232.0/24;
real_ip_header X-Forwarded-For;
...
}
varnish
sub vcl_recv {
...
if (req.restarts == 0) {
if (req.http.X-Forwarded-For) {
set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip;
} else {
set req.http.X-Forwarded-For = client.ip;
}
}
...
}
nginx
http {
...
set_real_ip_from 10.0.0.0/8;
real_ip_header X-Real-IP;
...
}