nginx转发https到tomcat报错403

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

cpp 复制代码
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中加上了日志打印发现

cpp 复制代码
request.getScheme()  #返回的总是 http,而不是实际的http或https

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

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

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

相关推荐
.柒宇.10 小时前
nginx入门教程
运维·nginx
极创信息15 小时前
信创系统认证服务怎么做?从适配到验收全流程指南
java·大数据·运维·tomcat·健康医疗
day day day ...19 小时前
MyBatis条件误写引发的查询条件污染分析与防范
java·服务器·tomcat
如来神掌十八式20 小时前
nginx + spring gateway+spring 服务_nginx 转发到 gateway
nginx·spring·gateway
hotlinhao21 小时前
Nginx rewrite last 与 redirect 的区别——Vue history 模式短链接踩坑记录
前端·vue.js·nginx
chxii21 小时前
在IIS中开启http跳转到https 和 http2的介绍
前端·http·https
camellias_1 天前
【无标题】
java·tomcat
tryCbest2 天前
Nginx常用操作命令-Linux和Windows系统
linux·windows·nginx
身如柳絮随风扬2 天前
Tomcat 体系结构
java·tomcat
卓怡学长2 天前
w1基于springboot高校学生评教系统
java·spring boot·tomcat·maven·intellij-idea