Varnish is not always adding X-Forwarded-For

Kervin L. Pierre kervin at
Tue Aug 14 00:50:09 CEST 2012

Did you get an answer to this question?  I'm running into the same issue.

After piping "POSTs" to get around another issues, we noticed that X-forwarded-For is not being returned to the backend server.

Is there a way to guarantee that x-forwarded-for is present on backend requests, even on pipes?

Best regards,

Adevsoft Inc
Business Software Development

From: varnish-misc-bounces at [mailto:varnish-misc-bounces at] On Behalf Of Doug Eubanks
Sent: Friday, August 03, 2012 10:18 AM
To: varnish-misc at
Subject: Varnish is not always adding X-Forwarded-For

We need Varnish to always add X-Forwarded-For so that we can see the visitor's IP when they submit a poll answer.

We have this setup, but we are still seeing about half of our requests not include the X-Forwarded-For header.

sub vcl_pipe {
        set bereq.http.X-Forwarded-For = req.http.X-Forwarded-For;
        set bereq.http.X-Forwarded-For = regsub(bereq.http.X-Forwarded-For, "$", ", ");
        set bereq.http.X-Forwarded-For = regsub(bereq.http.X-Forwarded-For, "$", client.ip);
        set req.http.connection = "close";

Doug Eubanks
admin at
(919) 201-8750

More information about the varnish-misc mailing list