PHP $_SERVER['REMOTE_ADDR'] shows a Clouflare IP adress

bug
php

#1

I tried to get the visitor’s IP address in PHP with this code:

$ip = $_SERVER['REMOTE_ADDR'];
echo $ip;

It should show my IP adress, but the result is 162.158.89.33 .
I opened the site on my mobile, but it shows the same.
Any help?


#2

You need to rewrite the IP addresses. Assuming you are on Apache have a look at mod_remoteip. Also, search the forum for this here, as there are plenty of examples.


#3

I changed back my nameservers to the original, and now it’s working.
But now I can’t use cloudflare…


#4

Ehm, you didnt address my response.


#5

Because I don’t have permission to do that.
Only mail, nameserver and contacts.


#6

Thats why are not addressing my response?

Which settings? The webserver’s? In that case you need to contact your host.


#7

Use HTTP_CF_CONNECTING_IP instead of REMOTE_ADDR :slight_smile: