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

相关推荐
秋落风声5 小时前
内存池仿Nginx C++实现
c++·nginx
難釋懷6 小时前
Nginx反向代理
运维·nginx
李昊哲小课7 小时前
Ubuntu 在线安装最新版 Nginx
nginx·ubuntu
shy_snow8 小时前
Nginx解决跨域问题
运维·nginx
nailwl9 小时前
原生态部署librenms
网络协议·http·https
晨晖211 小时前
项目上传到gitee的两种方式,ssh和https
https·gitee·ssh
難釋懷12 小时前
Nginx基于反向代理的负载均衡
nginx·github·负载均衡
aloha_7891 天前
信息系统项目管理师选择题考前真题错题笔记汇总
java·笔记·学习·tomcat
未若君雅裁1 天前
微服务限流实战:Nginx 漏桶与网关令牌桶
java·nginx·微服务
果然途游1 天前
网络故障一步步排查流程
网络协议·https