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 天前
解决nginx错误:http://localhost:7000正常,http://localhost:7000/map 报错404
nginx·大剑师
xing-xing1 天前
Docker容器中Nginx站点根目录网页配置访问
nginx·docker
需要8261 天前
JVM 内存区域与对象创建:一次 GC 从哪来
java·jvm·spring boot·spring·servlet·tomcat
2501_916007472 天前
苹果商店iOS应用上架费用全面解析:开发者计划与审核费用计算
android·ios·小程序·https·uni-app·iphone·webview
Lsetea2 天前
证书没到期却报certificate has expired:OpenSSL定位中间证书与系统时间
运维·https·ssl证书·openssl·证书链
PC2005-cloud2 天前
Nginx 防盗链配置实战:用 referer 模块保护网站静态资源
nginx
2501_916008892 天前
如何实现iOS App代码混淆:SwiftShield使用指南
android·ios·小程序·https·uni-app·iphone·webview
SDWAN_Cheap2 天前
HTTPS到底加密了什么?
https·数据加密
2601_953824612 天前
基于SSM的水果超市管理系统
java·tomcat·maven
PHP实战开发录2 天前
Nginx上传大文件为什么报413
nginx·php·开发