修复 https 页面因为发送 http 请求造成请求异常的 Bug (混合链接错误)

错误概览

此bug是我在用nginx反向代理nextcloud时发现的,在使用nginx反向代理nextcloud后,访问由 CollaboraOnline 提供的 nextcloud office 文件预览套件预览office文件就会出现这个问题,导致文件无法预览成功。

Mixed Content: The page at 'https://plprice.netlify.app/' was loaded over HTTPS, 
but requested an insecure script 
'http://api.vworld.kr/req/search?service=search&version=2.0&request=search&format=json&type=ADDRESS&category=PARCEL&query=%EB%B4%89%EB%82%A8%EB%A6%AC%20720-9&callback=jQuery351016469620631517623_1610625986322&_=1610625986323'. 
This request has been blocked; the content must be served over HTTPS.

解决方案

方案一

添加到 html 文件头

<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">

方案二

如果是反向代理的话,那么可以直接给 Nginx 配置文添加请求头

add_header Content-Security-Policy "upgrade-insecure-requests";
文章作者: 陕西颜值扛把子
本文链接:
版权声明: 本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 不挂高数
分享 Linux HTTP Nextcloud Nginx
喜欢就支持一下吧
打赏
微信 微信
支付宝 支付宝