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

相关推荐
Sayai16 小时前
Hadoop 集群安全加固实战:YARN 未授权访问漏洞修复,firewalld 白名单 + Nginx 反向代理 Basic Auth 全流程
运维·hadoop·nginx·安全·网络安全
梁云亮17 小时前
在 IDEA 中运行 Tomcat 时,直接在 server.xml 中配置的 <Context> 无效
tomcat·intellij-idea·虚拟路径
光依旧1 天前
发版就掉请求?Spring Boot优雅停机的四步
运维·spring boot·nginx·高可用·优雅停机·mcp server
高级程序源2 天前
springboot校园外卖平台13676-计算机课程设计、毕业设计
java·vue.js·spring boot·后端·tomcat·maven·课程设计
Lsetea2 天前
OpenSSL读取加密私钥报bad decrypt:passin与口令来源排查
linux·https·ssl证书·openssl·私钥
Lsetea2 天前
OpenSSL报CA signature digest algorithm too weak:error 68与签名摘要排查
https·ssl证书·openssl·签名算法·证书链
Lsetea2 天前
curl报91 No OCSP response received:cert-status与OCSP装订排查
https·ssl证书·openssl·curl·ocsp
Lsetea2 天前
OpenSSL报self-signed certificate in certificate chain:error 19与信任根排查
https·ssl证书·openssl·curl·证书链