查找通过代理连接的客户端的IP地址 [英] Finding IP address of client connected through a proxy

查看:83
本文介绍了查找通过代理连接的客户端的IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以收集通过代理服务器连接到您网站的客户端的IP地址?

Is there a way to collect the IP address of a client connected to your website through a proxy server?

整个设置是一个内部LAN,通过sysadmin,我也可以控制代理计算机.我在网站服务器端使用PHP5.

The entire setup is an internal LAN and through the sysadmin, I have control over the proxy machine as well. I am using PHP5 for the website server side.

我在PHP中尝试了$_SERVER['REMOTE_ADDR'],但是此变量仅存储代理的IP地址.

I tried $_SERVER['REMOTE_ADDR'] in PHP but this variable just stores the IP address of the proxy.

有什么想法吗?

推荐答案

(在php中)标准解决方案是:

The standard solution (in php) is:

if ($_SERVER['HTTP_X_FORWARDED_FOR']){
    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} 
else{ 
    $ip = $_SERVER['REMOTE_ADDR'];
}

但是,正如第一个答案所说的那样,这完全取决于实际设置的标头.

But as the first answer says this all depends on the header actually being set.

这篇关于查找通过代理连接的客户端的IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆