最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

nginx转发https到tomcat报错403

维修 admin 33浏览 0评论

nginx转发https到tomcat报错403

http请求转发正常,https返回403,nginx配置已添加proxy相关参数

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中加上了日志打印发现

request.getScheme()  #返回的总是 http,而不是实际的http或https

tomcat开启https请求需要加上如下内容在conf/server.xml

<Valve className="org.apache.catalina.valves.RemoteIpValve"remoteIpHeader="X-Forwarded-For"protocolHeader="X-Forwarded-Proto"protocolHeaderHttpsValue="https"/>

加上后重启tomcat,https恢复正常

nginx转发https到tomcat报错403

http请求转发正常,https返回403,nginx配置已添加proxy相关参数

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中加上了日志打印发现

request.getScheme()  #返回的总是 http,而不是实际的http或https

tomcat开启https请求需要加上如下内容在conf/server.xml

<Valve className="org.apache.catalina.valves.RemoteIpValve"remoteIpHeader="X-Forwarded-For"protocolHeader="X-Forwarded-Proto"protocolHeaderHttpsValue="https"/>

加上后重启tomcat,https恢复正常

与本文相关的文章

发布评论

评论列表 (0)

  1. 暂无评论