【问题标题】:request has been blocked; the content must be served over HTTPS请求已被阻止;内容必须通过 HTTPS 提供
【发布时间】:2018-12-18 12:26:52
【问题描述】:

我在后端使用 Spring Security 和 Spring MVC,在前端使用 Angular。
我的问题是我正确地登录了,但是我在我的本地主机中正确实现了注销的问题:http://localhost:8080 没有问题。当我将其更改为 https:// 时,我收到此错误:

混合内容:“”处的页面是通过 HTTPS 加载的,但请求了不安全的 XMLHttpRequest 端点“”。此请求已被阻止;内容必须通过 HTTPS 提供。

我想知道如何纠正?以及如何知道浏览器中的https阻止了哪个url,例如chrome?

【问题讨论】:

    标签: angularjs spring-mvc spring-security


    【解决方案1】:

    这篇文章可以解决您的问题:http://www.learningthegoodstuff.com/2015/08/mixed-http-error-with-spring-security.html

    所有细节都在那里解释,基本上你所要做的就是将这两行添加到我的 application.properties 文件中:

    server.tomcat.remote_ip_header=x-forwarded-for
    server.tomcat.protocol_header=x-forwarded-proto
    

    【讨论】:

    • 感谢您的回答,我试过了,但还是不行
    【解决方案2】:

    【讨论】:

      【解决方案3】:

      当服务器使用http(非安全)时会发生这种情况。您可以通过对后端的所有资源强制执行 https 来修复它。详情请查看here

      【讨论】:

        【解决方案4】:

        在@Jabir Minjibir 的回答中有很好的链接来描述错误。总而言之,当您的应用程序使用 httpS 方案时,您无法访问 http 的不安全链接。

        我收到了这个错误并修复了它,如下所示:

        Mixed Content: The page at 'https://stackblitz.com/' was loaded over HTTPS, but 
        requested an insecure XMLHttpRequest endpoint 'http://172.19.0.62:920/'. 
        This request has been blocked; the content must be served over HTTPS.
        

        您可以使用simple-https-proxy npm 包屏蔽不安全的链接。根据我的经验,我在httpS://stackblitz.com 上编写了一个角度示例,并且我试图连接到没有域名的 Elasticsearch 服务器。我需要让它与 ssl 一起工作,但我无法修改它的方案。因此,我安装了一个可以安全工作的代理 (httpS)。

        1. 我安装了 npm 包:
        npm i -g simple-https-proxy@latest
        

        1. 然后我创建了证书:
        simple-https-proxy --makeCerts=true
        
        1. 然后我运行它
        simple-https-proxy --target=http://172.19.0.62:9200 --port=9201 --rewriteBodyUrls=false
        

        在另一个例子中:

        【讨论】:

          猜你喜欢
          • 2015-03-23
          • 2016-08-28
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-08-29
          • 2022-01-11
          • 2016-03-01
          • 2018-08-30
          相关资源
          最近更新 更多