nginx反向代理tomcat 时,出现https redirect后变成http的问题解决方法

需要修改两个配置

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从重定向就不会串台了。

原文地址:https://www.cnblogs.com/irobotzz/p/12054954.html