Jeroen Jeroen - 1 month ago 7
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

mod_cloudflare


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

$_SERVER['REMOTE_ADDR']


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

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.