nginx反向代理tomcat 时,出现https redirect后变成http的问题解决方法
需要修改两个配置
1、nginx配置
1
2
3
4
5
6
7
8
9
10
|
location / { proxy_pass http: //test-server; 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; } |
2、修改tomcat下的conf/server/xml,在server.xml的Engine模块下面配置中上的Valve
1
2
3
4
|
<Valve className= "org.apache.catalina.valves.RemoteIpValve" remoteIpHeader= "X-Forwarded-For" protocolHeader= "X-Forwarded-Proto" protocolHeaderHttpsValue= "https" /> |
最后重启服务即可,https和http从重定向就不会串台了。