Laravel - 获取客户端IP地址 - 始终获得127.0.0.1结果 [英] Laravel - Get client IP address - Getting always 127.0.0.1 result
本文介绍了Laravel - 获取客户端IP地址 - 始终获得127.0.0.1结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法获取我需要确定其当前位置的客户端的IP地址。
I'm unable to get the IP address of the client which I need to determine his current location.
我使用了request-> ip(), $ _SERVER ['REMOTE_ADDR']我总是得到127.0.0.1的结果,这不是我想要的。
I've used request->ip(), $_SERVER['REMOTE_ADDR'] and I always get a 127.0.0.1 result which is not what I want.
我做错了什么?
推荐答案
request-> ip()
将为您提供客户端IP。你得到 127.0.0.1
,因为你试图从同一台机器上访问你的本地项目。
request->ip()
will give you client IP. You're getting 127.0.0.1
in because you're trying to access your local project from the same machine.
这篇关于Laravel - 获取客户端IP地址 - 始终获得127.0.0.1结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文