当前位置:首页 > 编程笔记 > 正文
已解决

nginx转发https到tomcat报错403

来自网友在路上 181881提问 提问时间:2023-11-10 12:08:13阅读次数: 81

最佳答案 问答题库818位专家为你答疑解惑

http请求转发正常,https返回403,nginx配置已添加proxy相关参数

proxy_set_header  Host $host;
proxy_set_header  X-Real-IP  $remote_addr;
proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header  X-Forwarded-Proto  $scheme;
proxy_pass        http://127.0.0.1:8988;  

在nginx排查了很久,后来在tomcat中加上了日志打印发现

request.getScheme()  #返回的总是 http,而不是实际的http或https

tomcat开启https请求需要加上如下内容在conf/server.xml

<Valve className="org.apache.catalina.valves.RemoteIpValve"remoteIpHeader="X-Forwarded-For"protocolHeader="X-Forwarded-Proto"protocolHeaderHttpsValue="https"/>

加上后重启tomcat,https恢复正常

查看全文

99%的人还看了

猜你感兴趣

版权申明

本文"nginx转发https到tomcat报错403":http://eshow365.cn/6-37224-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!