drwj4061 2013-06-29 13:37
浏览 366
已采纳

通过VPN连接:PHP $ _SERVER仍然提供本地IP

I have setup a PPTP VPN server on AWS and everything works perfectly. When connected to my VPN e.g. www.getip.com shows the IP address of the VPN server.

So far so good...

On the same server I installed an Apache server where I run a PHP script to get me my own IP address:

$ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];

Regardless if I am connected to VPN this code shows my local IP. I am not using varnish or any similar caching.

Any idea why this is the case? - Are the $_SERVER variables saved in the PHP session?

Your help is very much appreciated.

[UPDATE] The problem is definitely linked to the fact that the VPN server and the PHP script are on the same server. If I put the script on a different server everything works as desired. If connected to the VPN I expect to see the public IP of the server (which is the VPN server at the same time).

  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 vs创建SQL Server数据库时出现“系统找不到指定的路径”
      • ¥15 网页超时时间设置失效
      • ¥15 有关绿色信贷毕业论文的问题
      • ¥30 关于#机器人#的问题,如何解决?
      • ¥15 求MATLAB函数ScalarLayerDisplay的代码
      • ¥15 安卓如何自动执行检测到的NFC标签,无需再点确认
      • ¥15 pyHM库mouse模块的ValueError错误
      • ¥15 python opencv 摄像头 传感器
      • ¥30 eMMC&Android&C&Linux
      • ¥15 uniapp ios恢复购买