http网页是否能引用https资源/调用https接口?https网页是否能引用http资源/调用http接口?...

    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> 
      
      
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值