1. 程式人生 > >JS錯誤:Mixed Content: The page at ‘https://XXX’ was loaded over HTTPS, but requested an insecure

JS錯誤:Mixed Content: The page at ‘https://XXX’ was loaded over HTTPS, but requested an insecure

JS錯誤:Mixed Content: The page at ‘https://XXX’ was loaded over HTTPS, but requested an insecure

1、環境

Tomcat Nginx 【走https 通道】 框架形式是以 iframe 作為支撐的

2、問題

主體框架可以正常載入, 但是內部藉口和 iframe 裡面的內容以及靜態資源全部報錯

3、讓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;
4、讓Tomcat 識別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的