LoadBalancer-->Varnish-->Nginx : Real IP Address

Hi Guys,

Been scratching my head for a few hours now and wanted to see if anyone can help.

1) I have a load balancer with 6 servers in the back end.

2) The back end servers are Nginx and to get the real IP addresses of the visitors, all I have to do is the following in each Nginx install and I am able to get the real client IP address of each visitor.

setrealip_from; <– to handle the load balancer IP

realipheader X-Forwarded-For;

3) Now I have installed Varnish in front of each Nginx running on doing caching and for some reason now Nginx doesn't see the real client Ip addresses anymore coming from LoadBalancer --> Varnish --> Nginx

It's printing the following:

IP address: <-- this should be the real client IP address and not the 192.168 (assuming the load balancer IP address is being printed)

More detailed host address:

Many thank if you can help.


3 Replies

Looks like mangling XForwardedFor may be a known issue in Varnish?


Not too sure.




realipheader X-Forwarded-For;

Works for me with Varnish in front of Nginx on the same server. No load balancer though.


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct