JS错误:Mixed Content: The page at ‘https://XXX’ was loaded over HTTPS, but requested an insecure 新的问题

文章目录

  • JS错误:Mixed Content: The page at ‘https://XXX’ was loaded over HTTPS, but requested an insecure 新的问题
        • 1、修改nginx 配置参考
        • 2、让nginx 携带信息
        • 3、修改tomcat 的 Connector 以支持https
        • 4、tomcat 配置文件,仅供参考

JS错误:Mixed Content: The page at ‘https://XXX’ was loaded over HTTPS, but requested an insecure 新的问题


1、修改nginx 配置参考

参考之前的一篇文章:https://blog.csdn.net/qq_15071263/article/details/82881542

但是并不是每次都能解决问题

2、让nginx 携带信息

nginx 在转发时,需要携带一些真实信息进行转发

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 配置文件,仅供参考

server
{
    listen 80;
	listen 443 ssl http2;
    server_name god.mode.wretchant.com;
    index index.php index.html index.htm default.php default.htm default.html;
    root /www/wwwroot/god.mode.wretchant.com;
    
    if ($server_port !~ 443){
        rewrite ^(/.*)$ https://$host$1 permanent;
    }
    ssl_certificate    /www/server/vhost/cert/god.mode.wretchant.com/fullchain.pem;
    ssl_certificate_key    /www/server/vhost/cert/god.mode.wretchant.com/privkey.pem;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    error_page 497  https://$host$request_uri;

    location ~ /purge(/.*) {
        proxy_cache_purge cache_one $host$1$is_args$args;
        #access_log  /www/wwwlogs/god.mode.wretchant.com_purge_cache.log;
    }
    
    access_log  /www/wwwlogs/god.mode.wretchant.com.log;
    error_log  /www/wwwlogs/god.mode.wretchant.com.error.log;
}

反向代理配置,仅供参考的配置文件

location /
{
    expires 12h;
    if ($request_uri ~* "(php|jsp|cgi|asp|aspx)")
    {
         expires 0;
    }
    proxy_pass http://localhost:8080;
    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 REMOTE-HOST $remote_addr;
    
    add_header X-Cache $upstream_cache_status;
    add_header Cache-Control no-cache;
}

3、修改tomcat 的 Connector 以支持https

通过修改Connector 的配置为如下配置时,即可解决,不再需要添加Engine 下的Value,改了没用

    <Connector port="8080"
              protocol="HTTP/1.1"
              connectionTimeout="20000"
              redirectPort="8443"
              maxThreads="1000"
              minSpareThreads="20"
              acceptCount="1000"
			  scheme="https"
			  secure="true"
              maxHttpHeaderSize="65536"
              disableUploadTimeout="true"
              useBodyEncodingForURI="true"
              enableLookups="false"
              URIEncoding="UTF-8" />

改为之后,让tomcat 重载配置文件即可

4、tomcat 配置文件,仅供参考

版本:TOMCAT 9.0.0.M18




<Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  
  
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

  
  <GlobalNamingResources>
    
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  GlobalNamingResources>

  
  <Service name="Catalina">

    
    


    
    <Connector port="8080"
              protocol="HTTP/1.1"
              connectionTimeout="20000"
              redirectPort="8443"
              maxThreads="1000"
              minSpareThreads="20"
              acceptCount="1000"
			  scheme="https"
			  secure="true"
              maxHttpHeaderSize="65536"
              disableUploadTimeout="true"
              useBodyEncodingForURI="true"
              enableLookups="false"
              URIEncoding="UTF-8" />
    
    
    
    
    
    

    
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


    

    
    <Engine name="Catalina" defaultHost="localhost">

      
      

      
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      Realm>

      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

        
        

        
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t "%r" %s %b" />

      Host>
    Engine>
  Service>
Server>

你可能感兴趣的:(#,nginx,网络,-,http/https)