环境:
NGINX(HTTPS) -->TOMCAT
报错:
错误:Mixed Content: The page at ‘https://XXX’ was loaded over HTTPS, but requested an insecure........
主体框架可以正常加载, 但是内部借口和 iframe 里面的内容以及静态资源全部报错
解决方法:
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;
重点在最后一条
2.让tomcta识别https
修改tomcat server.xml 里的 Engine 模块下配置一个 Value:
<Valve className="org.apache.catalina.valves.RemoteIpValve"
remoteIpHeader="X-Forwarded-For" protocolHeader="X-Forwarded-Proto"
protocolHeaderHttpsValue="https"/>
其中
X-Forwarded-Proto 属性是为了让tomcat 识别请求是http的还是https的