Tell me more ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We have our setup as follows: 1. Varnish (Receives traffic and serves from cache whenever possible) 2. Haproxy (on same machine with Varnish, load balance requests to web servers) 3. Apache (in separate servers, traffic balanced by Haproxy).

Now I want to log real user IP in web server access log, for which I have enabled logging of "X-farwarded-for" header which is logging "127.0.0.1".

Enabled this header in Varnish (relevant lines from default.vcl):

  sub vcl_pipe {
  set req.http.connection = "close";
  return (pipe);
  }

  sub vcl_fetch {
    set    req.http.X-Forwarded-For = req.http.rlnclientipaddr;
    return(deliver);
  }

Also enabled in HAProxy (relevant lines from config file):

    option http-server-close
    option forwardfor except 127.0.0.1

Needs suggestions where things needs to be fixed for getting real user IP in backend server.

share|improve this question
You probably need to remove that configuration from HAProxy, since you want Varnish to set this header. – mgorven Jun 19 '12 at 6:20

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.