【谷歌浏览器】中(Mixed Content错误,即是https请求http在浏览器中出现的错误)的解决方法
zhangqi8869 2024-07-24 12:33:01 阅读 67
一、问题详情
Mixed Content: The page at ‘https://xxx’ was loaded over HTTPS, but requested an insecure test ‘http://xxx’. This request has been blocked; the content must be served over HTTPS.
注:上图中蓝色标记的【test】是http请求最后一级目录的关键字,也就是展示当前出现问题的目录关键字。
二、解决方式(两种方法选择其一即可)
2.1、方法一,在前端相应的HTML页面的head中加入meta标签元素(意思是自动将http的不安全请求升级为https),内容如下:
<code><meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">code>
2.2、方法二,在Nginx的Server中配置【add_header Content-Security-Policy upgrade-insecure-requests;】
<code>server
{
listen 80;
server_name xxx.test.com;
index index.php index.html index.htm default.php default.htm default.html;
root /www/wwwroot/xxx.test.com;
add_header Content-Security-Policy upgrade-insecure-requests;
try_files $uri $uri/ /index.html;
gzip_static on;
}
声明
本文内容仅代表作者观点,或转载于其他网站,本站不以此文作为商业用途
如有涉及侵权,请联系本站进行删除
转载本站原创文章,请注明来源及作者。