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

相关推荐
小张快跑。1 小时前
Tomcat下载、安装及配置详细教程
java·服务器·tomcat
探索java4 小时前
Tomcat Server 组件原理
java·后端·tomcat
水冗水孚6 小时前
图文并茂讲解nginx中http升级https(部署SSL证书)知识点总结
nginx·http·https
平行绳6 小时前
免费证书有效期越来越短了!本文教你设置自动更新证书,超详细!
后端·https
spencer_tseng21 小时前
Eclipse Tomcat Configuration
eclipse·tomcat
HYI1 天前
小公司前端多分支测试太痛苦?我自己写了个轻量 CLI
nginx·vite
芥子沫1 天前
Jenkins常见问题及解决方法
windows·https·jenkins
timeweaver1 天前
深度解析 Nginx 前端 location 配置与优先级:你真的用对了吗?
前端·nginx·前端工程化
Moment1 天前
nginx 如何配置防止慢速攻击 🤔🤔🤔
前端·后端·nginx
甄超锋2 天前
Java ArrayList的介绍及用法
java·windows·spring boot·python·spring·spring cloud·tomcat