nginx转发时,客户端的信息默认是不会传递给tomcat的
需要在nginx.conf中配置
location / {
proxy_pass http://localhost:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_intercept_errors on;
}
Nginx转发配置详解
本文介绍了如何在Nginx中正确配置转发规则,确保客户端信息能够被正确地传递到Tomcat服务器。通过设置proxy_pass及相关的proxy_set_header指令,可以实现HTTP请求头的透传,这对于维护客户端真实IP地址等信息至关重要。
1万+

被折叠的 条评论
为什么被折叠?



