nginx + Varnish and IP logging

Hi all,

I've got varnish in front of nginx and everything is working perfectly.

One problem - all IP's in my access logs are 127.0.0.1

I've configured varnish to pass the client IP via a http header:

sub vcl_recv {
  # Add a unique header containing the client address
  remove req.http.X-Forwarded-For;
  set    req.http.X-Forwarded-For = client.ip;

I see that nginx has a RealIP module but it's not enabled by default (crazy).

The problem I have is that I've installed nginx via apt-get rather than compiling from source.

Do I need to remove nginx and reinstall from source or is there a way to enable real ip from the apt-get packaged version?

1 Reply

If the module is missing from the package, you will not be able to use it without recompiling or installing from a different source.

For Ubuntu, you can give the 'official' nginx PPA a try: https://launchpad.net/~nginx/+archive/stable

the nginx-full and nginx-extras packages include the RealIP module. I'd rather evaluate this PPA's packages instead of compiling from source, esp. if you don't have any specific needs.

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