nginx 網站頁面JS報錯 Mixed Content The page at ‘httpsXXX’ was loaded over HTTPS, but requested an insecure


環境:

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的


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM