Thanks to visit codestin.com
Credit goes to github.com

Skip to content

getClientIp 方法获取IP不唯一 #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
seb-zhu opened this issue Aug 8, 2022 · 1 comment
Open

getClientIp 方法获取IP不唯一 #137

seb-zhu opened this issue Aug 8, 2022 · 1 comment

Comments

@seb-zhu
Copy link

seb-zhu commented Aug 8, 2022

\PhalApi\Tool::getClientIp();
获取IP时,可能存在不唯一的情况,在本地多次反向代理后,会把 ,127.0.0.1 也加上了。
通常我们需要取唯一的IP地址,而不是数据
故需要取数据的第0个值。

@phalapi
Copy link
Owner

phalapi commented Aug 8, 2022

感谢提醒。

目前有两个解决方案:
方案1、在本地配置反向代理时,取消把【 ,127.0.0.1】也加上
方案2、再封装一个获取IP的方法,兼容处理多个IP的情况

此外,\PhalApi\Tool::getClientIp(); 后续会再看下如何调整和兼容。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants