Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache http请求头中地址为192.168.0.0网络的Ip地址_Apache_Http_Http Headers_Ip_Mod Perl - Fatal编程技术网

Apache http请求头中地址为192.168.0.0网络的Ip地址

Apache http请求头中地址为192.168.0.0网络的Ip地址,apache,http,http-headers,ip,mod-perl,Apache,Http,Http Headers,Ip,Mod Perl,在Apache1.3中使用mod_perl。 客户端的地址获取头X-Forwarded-For、HTTP_X_Forwarded_FO或环境变量$ENV{REMOTE_ADDR}: sub address { my $self = shift; unless(defined $self->{address}){ my $header = $self->apache->headers_in->{'X-Forwarded-For'} ||

在Apache1.3中使用mod_perl。 客户端的地址获取头X-Forwarded-For、HTTP_X_Forwarded_FO或环境变量$ENV{REMOTE_ADDR}:

sub address {
    my $self = shift;
    unless(defined $self->{address}){
        my $header = $self->apache->headers_in->{'X-Forwarded-For'} ||
            $ENV{HTTP_X_FORWARDED_FOR} || '';
        my ($ip) = $header =~ /([^,\s]+)$/;
        $self->{address} = $ip || $ENV{REMOTE_ADDR} || ''; 
    }
    return $self->{address};
}

问题是有时会有地址,比如192.168.200.11、192.168.1.156、192.168.0.73。尽管服务器未连接到网络192.168.0.0。

因为您正在明确查看标头(如果所有代理正确设置),该标头将包含所有中间IP和原始客户端IP。因为大多数人都在本地家庭网络中,所以大多数原始IP都在192.168.xx.xx范围内