User IP Addresses

(Adam) #1

I’ve found a few posts that cover the server IP address showing up for every visitor and I understand servers being behind proxies / load balancers. I deal with the later so in my config.ini.php I have proxy_client_headers[] set as “HTTP_X_FORWARDED_FOR”.

However I’m using the the PHP API on one site (no alternative as I need to track a php php that outputs an image) and I’m getting the server IP. In the script I’m tracking the both REMOTE_ADDR and HTTP_X_FORWARDED_FOR have the right IP so it’s getting lost along the way somewhere.

Where can I look as I’m lost at the moment!



(Adam) #2

Ignore found this which I managed to completely miss before!,53741

(Adam) #3

Ah no don’t ignore as I still seem to have a problem

iwikTracker::$URL = '';
$t = new PiwikTracker( $idSite = 1);
$t->setTokenAuth( 'authtoken here' );

Doesn’t work but manually setting the ip, e.g. to

$t->setIp( '' );

works fine.

Any hints?

works fine. I’ve tried REMOTE_ADDR too.

(Adam) #4

Ok it was HTTP_X_FORWARDED_FOR confusing things and me being a little slow. Just in case anyone else looks for it I solved it this way:

$ip_array = explode(',', $ip);
$ip = $ip_array[0]; //gives first ip in array