Today I switched from the normal LAMP stack to the NVA Nginx Varnish Apache stack.

Tweaks needed are the following in PHP:

if (IsSet($_SERVER['HTTP_X_REAL_IP'])) {
  $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_REAL_IP'];
}

and setting the proxy stuff in piwik

proxy_client_headers[] = HTTP_X_REAL_IP

A newer post about the subject in my web server talk.