一、问题详情

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),内容如下:

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

2.2、方法二,在Nginx的Server中配置【add_header Content-Security-Policy upgrade-insecure-requests;】

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;}