the content must be served over HTTPS 解决方案

 

 报错的原因就是当前页面是https协议加载的,但是这个页面发起了一个http的ajax请求,这种做法是非法的。HTTPS页面里动态的引入HTTP资源,比如引入一个js文件,会被直接block掉的. 在HTTPS页面里通过AJAX的方式请求HTTP资源,也会被直接block掉的。

客户端解决办法

可以在相应的页面的<head>里加上这句代码,意思是自动将http的不安全请求升级为https

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

服务器端解决办法

配置一下 Nginx 和 Tomcat 

nginx location 添加

location / {
           ...
     proxy_set_header X-Forwarded-Proto  $scheme;
        
}

Tomcat server.xml 的 Engine 模块下配置一个 Valve

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

 

posted @ 2021-05-07 11:17  我又无所求  阅读(3283)  评论(0)    收藏  举报