3

I'm trying to edit the default.vcl file to get the real client IP addresses to show up in my Wordpress. I found this online and I read a lot of pages on this but have failed to make this work. I'm using varnish-4.0.1 revision 4354e5e.

I added this to the VCL file,

sub vcl_recv {
    remove req.http.X-Forwarded-For;
    if (req.http.cf-connecting-ip)
    {
        set req.http.X-Forwarded-For = req.http.cf-connecting-ip;
    }
    else
    {
        set req.http.X-Forwarded-For = client.ip;
    }
}

However, after this, the varnish service fails to start. The moment I go back to the default VCL file, everything goes back to normal again. Can anyone please help me make this work? I also use Cloudflare btw.

hpb
  • 43
  • 1
  • 5
  • Check if your varnish syntax is correct by command `varnishd -C -f /path/to/varnish.vcl` http://codepoets.co.uk/2011/checking-varnish-configuration-syntax/ – masegaloeh Jul 06 '14 at 05:19

1 Answers1

1

you need to check your VCL against Varnish 4
https://www.varnish-cache.org/docs/trunk/whats-new/upgrading.html

ADM
  • 1,373
  • 12
  • 16