• 當前位置:首頁 > IT技術 > Web編程 > 正文

    http網頁是否能引用https資源/調用https接口?https網頁是否能引用http資源/調用http接口?
    2021-12-13 17:57:02

      1. http網頁引用https資源 -> 可以

        ?

        ?

      2. http網頁調用https接口 -> 可以

        ?

        ?

      3. https網頁引用http資源 -> 不行(瀏覽器認為不安全)

        ?

        ?



        推薦解決方法,不指定具體協議,使用資源協議自適配,比如,當前為https頁面,那么就是https資源,如果是http頁面,那么就是http資源。具體方法超簡單:<script src='//www.aa.com/jquery.js'></script>

      4. https網頁調用http接口 -> 不行(瀏覽器認為不安全)

        ?

        ?



        推薦解決方案:nginx 配置https 轉http

        配置如下: 
        
        server { 
            listen       80; 
            server_name  localhost; 
             
             return 301 https://localhost$request_uri; 
             charset UTF-8; 
        
        
            location / { 
              root   html;                  # 這個是指定一個項目所在目錄 
              index  index.html index.htm;  # 這個是指定首頁的文件名 
            } 
        } 
        
        
        server { 
            listen       80 default backlog=2048; 
            listen       443 ssl; 
            server_name  localhost; 
        
            ssl_certificate      buduhuisi.crt;  # 這個是證書的crt文件所在目錄 
            ssl_certificate_key  buduhuisi.key;  # 這個是證書key文件所在目錄 
        
            ssl_session_cache    shared:SSL:1m; 
            ssl_session_timeout  5m; 
        
            ssl_ciphers  HIGH:!aNULL:!MD5; 
            ssl_prefer_server_ciphers  on; 
        
            location /esgcc-oms { 
                                proxy_pass         http://localhost:8080; 
                            proxy_redirect http:// https://; 
                                add_header         Cache-Control    no-store; 
                                proxy_set_header   Host             $host; 
                                proxy_set_header   X-Real-IP        $remote_addr; 
                                proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for; 
        
                     } 
        
            location / { 
              root   html;                  # 這個是指定一個項目所在目錄 
              index  index.html index.htm;  # 這個是指定首頁的文件名 
            } 
        } 
        
        
        
        proxy_redirect http:// https:// 這個配置是解決重定向后https變成了http 的問題。 
        
        應用中配置: 
            <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
                <property name="prefix" value="/pages/" /> 
                <property name="suffix" value=".jsp" /> 
                <property name="order" value="1" /> 
                <property name="redirectHttp10Compatible" value="false" />   <!--重定向解決https 變成了http 的問題--> 
            </bean> 
        

          

    本文摘自 :https://www.cnblogs.com/

    開通會員,享受整站包年服務
    国产呦精品一区二区三区网站|久久www免费人咸|精品无码人妻一区二区|久99久热只有精品国产15|中文字幕亚洲无线码