0
I put Cloudflare on my system, but it’s playing the role of a "reverse proxy on account of CDN’s DNS".
But when I give one ping -t meusiteaqui.com
it returns the real IP address of the server, but in request it is with the Cloudflare proxy.
0
I put Cloudflare on my system, but it’s playing the role of a "reverse proxy on account of CDN’s DNS".
But when I give one ping -t meusiteaqui.com
it returns the real IP address of the server, but in request it is with the Cloudflare proxy.
0
Since Cloudflare is acting as proxy, the IP of the user accessing the page is overridden by the Cloudflare IP.
Of Stack Overflow in English (free translation with some modifications):
Extra server variables available from Cloudflare for these purposes are:
$_SERVER["HTTP_CF_CONNECTING_IP"]
Actual IP of the user (That’s what you want);$_SERVER["HTTP_CF_IPCOUNTRY"]
user’s country;$_SERVER["HTTP_CF_RAY"]
⇒ learn more here;$_SERVER["HTTP_CF_VISITOR"]
helps determine if the protocol is http
or https
.You can then use like this:
if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
}
Or directly access:
$_SERVER["HTTP_CF_CONNECTING_IP"]
Note that if you do this, it is important to check that $_SERVER["REMOTE_ADDR"]
contains the true Cloudflare IP, as anyone can modify the header if they are able to connect directly to the server IP.
Browser other questions tagged php apache server ip
You are not signed in. Login or sign up in order to post.