Not getting the real ip address of client


#1

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

FW—>LOAD BALANCER—>PIWIK HOST

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


(vipsoft) #2

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

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


[General]
proxy_client_headers[] = HTTP_X_FORWARDED_FOR
proxy_host_headers[] = HTTP_X_FORWARDED_HOST


#3

thanks so much got it working…


#4

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.
Cheers,
-David.


(Matthieu Aubry) #5

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


#6

HTTP_X_FORWARDED_PORT 80
HTTP_X_FORWARDED_PROTO http
HTTP_X_FORWARDED_FOR 72.149.34.249, 10.251.26.175
SERVER_ADDR 10.126.229.27
SERVER_PORT 80
REMOTE_ADDR 10.120.255.118

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…

Thanks.


(vipsoft) #7

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