To forward the correct IP from Varnish to piwik, make sure that req.http.X-Forwarded-For is set to client.ip in vcl_recv:
if (req.http.host == "piwik.domain.com") {
# Set the X-Forwarded-For to the client IP address.
set req.http.X-Forwarded-For = client.ip;
# Do not cache.
return(pass);
}
Note that the addition of set req.http.X-Forwarded-For = client.ip; is not needed if you are using the Wizardry and Steamworks Varnish template.
Finally, edit the piwik/config/config.ini.php file to add:
[General] proxy_client_headers[] = "HTTP_X_FORWARDED_FOR" proxy_host_headers[] = "HTTP_X_FORWARDED_FOR"