请求已被阻止;内容必须通过HTTPS提供

时间:2018-07-10 15:20:35

标签: angularjs spring-mvc spring-security

我正在使用Spring Security和Spring MVC在后端,而Angular在前端进行应用程序。
我的问题是我可以正确登录,但是退出的问题是我在本地主机上正确实现的:http://localhost:8080正常工作。当我将其更改为https://时,出现此错误:

  

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

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

4 个答案:

答案 0 :(得分: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

答案 1 :(得分:0)

答案 2 :(得分:0)

当服务器使用http(不安全)时,会发生这种情况。您可以通过对后端中的所有资源强制执行https来解决此问题。检查here了解更多详细信息。

答案 3 :(得分:0)

在@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

installing globally

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

enter image description here

在另一个示例中: enter image description here enter image description here enter image description here

相关问题