天天看點

錯誤:Mixed Content: The page at 'https://a.b.com/detail?id=5' was loaded over HTTPS, but reque

版權聲明:本文為部落客原創文章,未經部落客允許不得轉載。 https://blog.csdn.net/catoop/article/details/70247993

關于這個錯誤的詳細内容為:

Mixed Content: The page at 'https://a.b.com/detail?id=5' was loaded over HTTPS, but requested an insecure script 'http://a.b.com/xxxxxxx'. This request has been blocked; the content must be served over HTTPS.           

這個問題,或許你是再Chrome浏覽器的控制台看到的錯誤提示。

遇到這個問題,既然你百度到這裡了,不妨用下面的方法嘗試一下是否能解決你的問題。

先簡單說一下我的項目部署的結構:

1、nginx

2、tomcat

3、nginx 中配置 https,tomcat 正常使用的 http

出現問題的場景:在進行 redirect 重定向的時候會出現這個問題。

解決問題的過程就不多說了,最終定位的結果是“tomcat的協定http和nginx反向代理的協定https不一緻造成的”。

解決方法:

1、在反向代理那裡設定一個頭

X-Forwarded-Proto

,值設定成

https

2、在 Tomcat 的 server.xml 裡添加如下配置:

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

至此,解決我的問題。

如果解決不了你的問題,再百度看看其他資料^_^,很多問題的導緻原因可能是多種的。

繼續閱讀