通过CloudFlare获取正确的访客IP [英] Get correct visitor IP through CloudFlare

查看:365
本文介绍了通过CloudFlare获取正确的访客IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用从别人那里转售给我的cPanel。
这可能意味着我不能使用 mod_cloudflare

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

我想获取访问者的IP,而不是CloudFlare IP。
我正在使用的代码部分:

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

$_SERVER['REMOTE_ADDR']

该行将获取云光晕的IP,而不是原始用户的IP。

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

有什么办法可以从访问者那里获得原始IP地址吗?

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

推荐答案

是,但是无法访问服务器配置,您将无法使用 $ _ SERVER ['REMOTE_ADDR']

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

但是,您可以仍使用 X-Forwarded-For CF-Connecting-IP 。两者都可以在 $ _ SERVER 超级全局文件中使用。

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

这篇关于通过CloudFlare获取正确的访客IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆