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

相关推荐
Harvy_没救了1 天前
【网络部署】 Win11 + VMware CentOS8 + Nginx 文件共享服务 Wiki
运维·网络·nginx
遇见火星1 天前
Nginx限流配置:防止接口被刷,服务器稳如泰山
运维·服务器·nginx
KnowSafe1 天前
CLM最佳实践:构建高效证书生命周期管理体系
安全·https·clm·itrustssl·trustasia
PESS ABIN1 天前
JavaWeb项目打包、部署至Tomcat并启动的全程指南(图文详解)
java·tomcat
ShiJiuD6668889991 天前
Request和Response
tomcat
BduL OWED1 天前
Docker:基于自制openjdk8镜像 or 官方openjdk8镜像,制作tomcat镜像
docker·容器·tomcat
misL NITL2 天前
idea、mybatis报错Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required
tomcat·intellij-idea·mybatis
Jinkxs2 天前
LoadBalancer- 主流负载均衡工具盘点:Nginx / Haproxy / Keepalived 基础介绍
运维·nginx·负载均衡
KnowSafe2 天前
CaaS vs 传统管理:证书即服务的颠覆性优势
https·ssl
ReaF_star2 天前
【安全】SSL证书更新操作手册(Nginx+Cloudflare+acme.sh)
nginx·安全·ssl