Reputation: 650
I have a subscription to a pro offer at OVH. I think that the PHP environment isn't well configured because when I try to request the client IP with the environment it returns a private IP such as 10.X.X.X which changes every refreshing.
I tried to print the entire environment to see if the public IP is stored anywhere else, but it is not.
Have you got any ideas where it might come from?
Thanks.
Upvotes: 0
Views: 1519
Reputation: 4825
seems like you are testing from your localhost. On your live server, the ip address should be properly displayed. Here is a simple function to further assist you:
function getUserIpAddress() {
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
}
Upvotes: 0