在网站上找不到正确的IP地址

发布于 2025-01-26 01:58:40 字数 357 浏览 2 评论 0原文

我正在使用 https://enter.me/ 访问我网站的任何人。 ( https://notablee.co/get_ip ),

但我只是获得共享的托管IP(50.87.141.159 )而不是访问者IP地址。

$ip = file_get_contents('https://ident.me/');

I am using https://ident.me/ for getting IP of anybody who visits my web site. (https://notablee.co/get_ip)

But I am only getting the Shared Hosting IP (50.87.141.159) instead of the Visitors IP Address.

$ip = file_get_contents('https://ident.me/');

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

究竟谁懂我的在乎 2025-02-02 01:58:40
$ip=$_SERVER['REMOTE_ADDR'];

修复了这个。感谢“ Abronsius教授”的快速修复。

$ip=$_SERVER['REMOTE_ADDR'];

Fixed this. Thanks to 'Professor Abronsius' for a quick fix.

羁〃客ぐ 2025-02-02 01:58:40

虽然您的答案并非完全错误,但您应该考虑您的代码位于LoadBalancer或代理后面。在这种情况下,$ _server数组应包含字段x_http_forwarded_for,其中包含所有先前IP地址的列表作为逗号分隔的字符串。

也请阅读这篇文章
如何正确使用http_x_forwarded_for?

While your answer is not entirely wrong, you should consider that your code sits behind a loadbalancer or proxy. In this case, the $_SERVER array should contain the field X_HTTP_FORWARDED_FOR which contains a list of all previous IP addresses as a comma-separated string.

Also read this SO article
How to use HTTP_X_FORWARDED_FOR properly?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文