部署https后浏览器提示不安全,不出现绿色小锁?
網(wǎng)站部署https后,瀏覽器提示不安全, 不出現(xiàn)綠色小鎖圖標(biāo)?
訪問網(wǎng)站后,按f12,瀏覽器提示:
Mixed Content: The page at 'https://www.xxx.com/'' was loaded over HTTPS, but requested an insecure image 'http://www.xxx.com/uploads/2018/12/3.png'. This content
原因是在https頁面中,如果調(diào)用了http資源,那么瀏覽器就會拋出一些錯誤,
解決辦法:在header中加入Upgrade-Insecure-Requests,會告訴瀏覽器可以把所屬本站的所有http連接升級為https連接,外站請求保持默認;
添加header方法:
1.iis7
或直接在網(wǎng)站根目錄web.config中定義
<?xmlversion="1.0"encoding="UTF-8"?><configuration><system.webServer><httpProtocol><customHeaders><addname="Content-Security-Policy"value="upgrade-insecure-requests"/></customHeaders></httpProtocol></system.webServer></configuration>
2.apache
可直接在網(wǎng)站根目錄.htaccess中定義
<IFModulemod_headers.c>HeaderaddContent-Security-Policyupgrade-insecure-requests</IFModule>
3. nginx
server{listen80;server_name(myservername);add_headerContent-Security-Policy"upgrade-insecure-requests";location/{proxy_passhttp://localhost:5000;}}
總結(jié)
以上是生活随笔為你收集整理的部署https后浏览器提示不安全,不出现绿色小锁?的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 快速建站获取网站源码的两种方法!
- 下一篇: 怎样理解MapReduce中shuffl