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.