0

If I use the following configuration in varnish,

if (req.restarts == 0) {
        if (req.http.x-forwarded-for) {
        set req.http.x-forwarded-for = req.http.x-forwarded-for + ", " + client.ip;
        }
        else {
        set req.http.x-forwarded-for = client.ip;
        }
        }

and configure apache logformat like this,

LogFormat "%{X-Forwarded-For}i %t \"%r\" %>s %b \"%{User-agent}i\"" varnishcombined
        CustomLog ${APACHE_LOG_DIR}/access.log varnishcombined

I end up with the forwarded ip (client's ip) being displays twice in apache's logs. But if I simply use:

unset req.http.x-forwarded-for;
set req.http.x-forwarded-for = client.ip;

Then it works just fine. But the question is, why is the ip being shown twice in the first example?

I'm using Ubuntu 16.04.5, apache 2.4.18 and varnish 4.1.10-1~xenial.

2
  • this could probably be due to your logformat description in apache configuration a better place to refer would be here
    – Corleone
    Jul 24, 2018 at 15:48
  • Thank you. The link provided all the necessary information I needed.
    – Lethargos
    Aug 2, 2018 at 8:57

0

You must log in to answer this question.

Browse other questions tagged .