解决js加载使用http的问题

控制台错误提示:
Mixed Content: The page at '' was loaded over HTTPS, but requested an insecure script ''. This request has been blocked; the content must be served over HTTPS.
解决方案:
1.Nginx对应server的location添加配置

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

注意:如果nginx里配置的upstream是非具体IP的,不要写localhost,应该写127.0.0.1,类似如下:

upstream xxx{
        server 127.0.0.1:8080 weight=1;
}

2.Tomcat的配置srever.xml
2.1 connector里添加

redirectPort="443" proxyPrort="443"

最终效果是: <Connector port="8006" protocol="AJP/1.3" redirectPort="443" proxyPrort="443" />

2.2 Host里新增

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

相关文章:

  • 2022-02-08
  • 2021-11-19
  • 2021-07-20
  • 2021-11-05
  • 2021-05-25
  • 2021-11-21
  • 2021-11-12
猜你喜欢
  • 2021-12-03
  • 2022-01-10
  • 2022-02-21
  • 2022-12-23
  • 2021-07-22
  • 2021-10-01
  • 2022-01-14
相关资源
相似解决方案