Caunter, Stefan scaunter at
Sat Jan 15 18:47:12 CET 2011

-----Original Message-----
From: varnish-misc-bounces at
[mailto:varnish-misc-bounces at] On Behalf Of Frank
Sent: January-15-11 3:31 AM
To: varnish-misc at
Subject: HTTP_X_FORWARDED_FOR handling


I'm using varnish-2.1.4 SVN 5447M and wonder how HTTP_X_FORWARDED_FOR
gets treatened by varnish.

In my VCL (which i partly copied from elsewhere) there are some lines
that i found in many VCLs around the net:

-- snip --

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


I think this should do what i need: set a HTTP_X_FORWARDED_FOR header
containing the real client IP-Address and add it to the requests that
hit the backend. These lines are within sub vcl_recv.

I need the Client IP at the backend for some statistic stuff (ip based

Unfortunately i don't even get an empty HTTP_X_FORWARDED_FOR header.
It basically doesn't exist. I tried commenting these lines out and
also tried client.ip instead of req.http.rlnclientipaddr; as i found
this somewhere else - i don't know which the correct syntax is.

Is there anything else wrong? Or maybe some switch in my varnish
version that i need to set to make HTTP_X_FORWARDED_FOR appear for my


You don't get X-F-F unless you are going through some kind of appliance
load balancer.
As mentioned earlier, rewrite it to be client.ip if you need it.

Stefan Caunter 
e: scaunter at  ::  m: (416) 561-4871 

More information about the varnish-misc mailing list