在网站上找不到正确的IP地址
我正在使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
修复了这个。感谢“ Abronsius教授”的快速修复。
Fixed this. Thanks to 'Professor Abronsius' for a quick fix.
虽然您的答案并非完全错误,但您应该考虑您的代码位于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?