With default config nginx all IP addresses shows as localhost.
Here is configuration to show real client IP.
Snippet from varnish config:
sub vcl_pipe {
set bereq.http.connection = "close";
if (req.http.X-Forwarded-For) {
set bereq.http.X-Forwarded-For = req.http.X-Forwarded-For;
} else {
set bereq.http.X-Forwarded-For = regsub(client.ip, ":.*", "");
}
}
sub vcl_pass {
set bereq.http.connection = "close";
if (req.http.X-Forwarded-For) {
set bereq.http.X-Forwarded-For = req.http.X-Forwarded-For;
} else {
set bereq.http.X-Forwarded-For = regsub(client.ip, ":.*", "");
}
}
Snippet from nginx config:
set_real_ip_from 127.0.0.1;
real_ip_header X-Forwarded-For;
great !
it ‘s work perfectly
thks a lot
Thanks. Your method worked even when the other methods have failed to get the real ip.
works 100% thx!!1!
Where could I put these?
set_real_ip_from 127.0.0.1;
real_ip_header X-Real-ip;
it may be entered in three places according to Your configuration:
http, server or location
more info:
http://wiki.nginx.org/HttpRealipModule
For getting client ip in application like PHP, ASP visit getting-real-client-ip-through-varnish/
Thank you Sooooo muchhhh