getting ip address using PHP in case you are running VPN

三世轮回 提交于 2019-12-04 21:25:01

No. Whatever PHP (rather the web server) returns is the address that the request was made from. There's no way for the script to know if you're behind a VPN or proxy.

Try the following - I'm not behind a proxy or VPN, so can't check right now:

$_SERVER['HTTP_X_FORWARDED_FOR']; // in place of REMOTE_ADDR

You can also try referencing SERVER_NAME using:

$_SERVER['HTTP_X_FORWARDED_HOST'];
$_SERVER['HTTP_X_FORWARDED_SERVER'];

Not sure what you'll get on a VPN. I know that anonymous proxies won't populate these variables.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!