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 天前
使用Vue 3和Nginx打包和部署Vue.js项目的一般步骤
前端·vue.js·nginx
記億揺晃着的那天1 天前
HTTPS 页面内网直连 NAS:解决 Mixed Content 与公网带宽瓶颈
网络协议·http·https·nas
難釋懷1 天前
Nginx代理https请求
redis·nginx·https
chexus2 天前
21. 深入 Nginx HTTP 缓存源码:CDN功能
nginx·http·缓存
2501_916007473 天前
深入理解HTTPS对称与非对称加密机制及Charles抓包实践
网络协议·http·ios·小程序·https·uni-app·iphone
BelongPanda3 天前
Linux Nginx 纯手动 Let‘s Encrypt 泛域名证书配置教程
linux·nginx
2501_916008893 天前
HTTPS 抓包遇到证书绑定怎么办,使用 TraceEagle 解除 App 证书校验
网络协议·计算机网络·http·网络安全·ios·adb·https
郝亚军4 天前
nginx的三个基础库:PCRE、OpenSSL、Zlib的安装
linux·服务器·nginx
CodexDave4 天前
MySQL事务隔离级别与MVCC机制解析
前端·数据库·mysql·nginx·性能优化·负载均衡