如果要记录真实的客户端访问地址,需要进行如下配置:
1,反向代理服务器nginx。参看配置
在服务器后面增加三个参数用与记录IP:
proxy_set_header主机主机美元;
proxy_set_header X-Real-IP remote_addr美元;
proxy_set_header X-Forwarded-For proxy_add_x_forwarded_for美元;
案例:
服务器{
听80;
server_name 10.10.32.29;
<代码>上游tomcat { ip_hash; 服务器10.10.32.29:8080 max_fails=1 fail_timeout=10 s重量=1; 服务器10.10.32.30:8080 max_fails=1 fail_timeout=10 s重量=1; } 位置/{代码>
proxy_pass http://tomcat;
proxy_redirect违约;
proxy_set_header主机主机美元;
proxy_set_header X-Real-IP remote_addr美元;#保留代理之前的真实客户端ip
proxy_set_header X-Forwarded-For proxy_add_x_forwarded_for美元;#记录代理过程
}
error_page 500 502 503 504/50 x.html;
=/50 x位置。html {
根html;
}
<代码>}代码>
2,修改tomcat的配置文件
在server.xml中修改
& lt;阀className=皁rg.apache.catalina.valves.AccessLogValve"目录=發ogs"=
前缀“localhost_access_log"后缀=?txt"
模式=? {X-FORWARDED-FOR}我% h % l % u % t“% r"% s % b"/在