需要修改两个配置
1、nginx配置
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
<Valve className="org.apache.catalina.valves.RemoteIpValve" remoteIpHeader="X-Forwarded-For" protocolHeader="X-Forwarded-Proto" protocolHeaderHttpsValue="https"/>
最后重启服务即可,https和http从重定向就不会串台了。