This version (2014/11/08 14:11) was approved by alex.

Running Piwik with Cloudflare

After switching my site to Cloudflare CDN, I noticed that the IPs showing are no longer the clients IPs, but the ones from Cloudflare, which is similar to running a site behind a reverse proxy (in essence I assume Cloudflare is doing exactly that). This require a small config change in piwik to evaluate the client IP correctly. (the same solution can be applied as for a regular reverse proxy, but Cloudflare provides a specific header field for that).

Add the following lines to the end of the config/config.ini.php file:

proxy_client_headers[] = "HTTP_CF_CONNECTING_IP"

If the [General] section already appears in your config, just add the 2nd line to the section.

For some reason this is not enough since it breaks the form security of the login form, so if you get this error message:

Error: Form security failed. Please reload the form and check that your cookies are enabled. If you use a proxy server, you must configure Piwik to accept the proxy header that forwards the Host header. Also, check that your Referrer header is sent correctly.

To fix this either wait a while (probably since the session is invalidated) or delete the cookie PIWIK_SESSID on your domain.

This way the proper IPs should appear in the analytics.