使用场景:nginx+tomcat,nginx起反向代理作用,由于没有做以下配置,结果在tomcat部署的jia-web通过request.getHeader("X-Forwarded-For")总是返回127.0.0.1:
server {
listen 80;
server_name xx.com;
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_set_header X-NginX-Proxy true;
location ~ /services {
proxy_pass http://127.0.0.1:18888;
}
location ~ /{
proxy_pass http://127.0.0.1:8897;
}
}
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有