通过iframe加载网站时,哪个IP地址会在网站上被识别?

时间:2017-01-14 16:39:18

标签: php iframe

所以有2个网站A和B.

A有一个带iframe的页面加载B. 并且B具有检测访问者IP地址的后端代码,如下所示:

// Function to get the user IP address
function getUserIP() {
    $ipaddress = '';
    if (isset($_SERVER['HTTP_CLIENT_IP']))
        $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
    else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
        $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
    else if(isset($_SERVER['HTTP_X_FORWARDED']))
        $ipaddress = $_SERVER['HTTP_X_FORWARDED'];
    else if(isset($_SERVER['HTTP_X_CLUSTER_CLIENT_IP']))
        $ipaddress = $_SERVER['HTTP_X_CLUSTER_CLIENT_IP'];
    else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
        $ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
    else if(isset($_SERVER['HTTP_FORWARDED']))
        $ipaddress = $_SERVER['HTTP_FORWARDED'];
    else if(isset($_SERVER['REMOTE_ADDR']))
        $ipaddress = $_SERVER['REMOTE_ADDR'];
    else
        $ipaddress = 'UNKNOWN';
    return $ipaddress;
}

如果用户访问A中的iframe页面,将获取哪个IP地址?

是客户的IP地址吗,

网站A的IP地址?

2 个答案:

答案 0 :(得分:3)

iframe元素代表nested browsing context。用户浏览器请求iframe源。因此,如果您检查IP地址,您将获得客户端IP。

答案 1 :(得分:0)

我猜它仍会获得客户端的IP地址? 因为iframe会发送几乎相同的标题。

也将发送客户端IP地址。