HTTP_X_FORWARDED_FOR handling

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


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

Hi,

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;

--/snip--

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
timeouts).

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
backend?

-----

Frank,
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 topscms.com  ::  m: (416) 561-4871
www.thestar.com 






More information about the varnish-misc mailing list