Not getting the real ip address of client

Hi I’m having problem on piwik… I can’t get the real ip address of client… my setup is like this


when I try to check the logs I see load balancer ip not the forward ip of client. other info piwik log it browser, os… etc… may piwik server is behin load balancer please help

In core/global.ini.php, there are examples on configuring proxy headers.

In your config/config.ini.php add (depending on your environment):

proxy_client_headers[] = HTTP_X_FORWARDED_FOR
proxy_host_headers[] = HTTP_X_FORWARDED_HOST

thanks so much got it working…

I’m also seeing this issue. I’ve just started running my setup in production behind an Amazon AWS EC2 ELB, which, according to the docs, uses X-Forwarded-For. I’ve put the lines above into config/config.ini.php, but it still records visit IPs as 10.x.x.x. Should there be quotes around the ini setting value or not? It is case sensitive? What about the HTTP prefix?
Any help appreciated.

David, run a <? phpinfo(); ?> and the see the name of the header where your IP is set, is it displayed correctly on the phpinfo ?


I’ve observed that some (not most) of the logged visits actually show the correct address. Perhaps piwik could just ignore any 10., 192. and 172.* IPs in the HTTP_X_FORWARDED_FOR header?

We have other PHP software under different Apache vhosts under the same infrastructure and that pulls the correct IPs - as do the Apache logs where we’ve explicitly logged the left-most IP in that header.

I can dig into the piwik code and debug if you give me a pointer where to look…


Refer to the example in global.ini.php to configure proxy_ips[].