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

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      40
      41
      42
      43
      44
      45
      46
      47
      48
      49
      50
      51
      52
      53
      54
      55
      56
      57
      58
      配置如下:
       
      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>

        

posted on   ygunoil  阅读(1034)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 通过 API 将Deepseek响应流式内容输出到前端
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示