Home Diary Blog Photo Community Open Source
Spring Boot redirect https 转为http的问题
错误:Mixed Content: The page at ‘https://XXX’ was loaded over HTTPS, but requested an insecure........

(1)配置 Nginx 的转发选项:

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; //或者将$scheme改为 https;

2)配置Tomcat server.xml 的 Engine 模块的Host下配置一个 Value: 

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

配置双方的 X-Forwarded-Proto 就是为了正确地识别实际用户发出的协议是 http 还是 https。

X-Forwarded-For 是为了获得实际用户的 IP。