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

相关推荐
何中应2 天前
Nginx转发请求错误
前端·后端·nginx
大大水瓶3 天前
Tomcat
java·tomcat
芝士雪豹只抽瑞克五3 天前
Nginx 高性能Web服务器笔记
服务器·nginx
失重外太空啦3 天前
Tomcat
java·服务器·tomcat
屎到临头想搅便3 天前
TOMCAT
java·tomcat
失重外太空啦3 天前
nginx
运维·nginx
微风起皱3 天前
企业级WEB应用服务器TOMCAT
java·前端·tomcat
天蓝不会忘记023 天前
lvs,haproxy,keepalived,nginx,tomcat介绍和实验
nginx·tomcat·lvs
feng68_3 天前
Nginx高性能Web服务器
linux·运维·服务器·nginx