Jeroen Jeroen - 1 year ago 84
PHP Question

Get correct visitor IP through CloudFlare

I'm using cPanel from someone else who resold it to me.
This will probably mean I cannot use


I would like to get the visitor's IP and not CloudFlare IP.
The part of code I'm using:


That line will get the IP of cloud flare and not the original user's IP.

Is there any way I can get the original IP address from the visitor?

Answer Source

Yes, but without access to the server configuration, you will be unable to utilize $_SERVER['REMOTE_ADDR'].

However, you can still use X-Forwarded-For and CF-Connecting-IP. Both would be available in the $_SERVER super-global.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download