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 192.168.255.0/24; <– to handle the load balancer IP

realipheader X-Forwarded-For;

3) Now I have installed Varnish in front of each Nginx running on 127.0.0.1 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:

192.168.255.9 <-- 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:

192.168.255.9

Many thank if you can help.

Dave

3 Replies

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

https://www.varnish-cache.org/forum/topic/110

Not too sure.

//heckman

Try:

setrealip_from 127.0.0.1;

realipheader X-Forwarded-For;

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

Reply

Please enter an answer
Tips:

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