nginx转发https到tomcat报错403

编程入门 行业动态 更新时间:2024-10-11 23:15:38

nginx转发https到tomcat<a href=https://www.elefans.com/category/jswz/34/1771188.html style=报错403"/>

nginx转发https到tomcat报错403

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恢复正常

更多推荐

nginx转发https到tomcat报错403

本文发布于:2023-11-16 01:49:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1611042.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:报错   https   nginx   tomcat

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!