Note: You will need a combination of varnish configuration and log configuration for the web server:
/etc/varnish/default.vcl
sub vcl_recv {
if (req.restarts == 0) {
if (!req.http.x-forwarded-for) {
set req.http.X-Forwarded-For = client.ip;
}