如何从 HTTPS 网站发出 HTTP 请求?

Ada*_*dam 7 javascript https http aws-lambda

我有一个基于 HTTPS 的网站,我想向 HTTP 端口发出 GET 请求。目前,当我尝试时,我收到以下错误:

cannot load ${url} due to access control checks.

this page was not allowed to display insecure content from ${http-url}
Run Code Online (Sandbox Code Playgroud)

我考虑过将请求放入 AWS lambda 函数并调用 labmda 函数,因为这会给我一个 HTTPS URL?这可能吗。

即便如此,我想知道最简单的方法是什么,因为我对 AWS 不太了解,所以我必须学习它。

const url = 'http://website/fmi/xml/fmresultset.xml?-dbnames';

var xhttp = new XMLHttpRequest(); 
xhttp.onreadystatechange = function (params) { 
  console.log(xhttp.status); 
  if (xhttp.readyState ==4) { 
    if (xhttp.status == 200) { 
      console.log('===='); 
      console.log(xhttp.responseText); 
    } 
  } 
} 
xhttp.open("GET", url, true); 
xhttp.send();
Run Code Online (Sandbox Code Playgroud)

fro*_*dev 6

如果原始 html 页面位于 https 且请求资源位于 http 中,那么浏览器将无法阻止任何资源( script 、 link 、 iframe 、 XMLHttpRequest 、 fetch )下载。

浏览器抛出Mixed Content错误。

来自 Mozilla MDN 的片段

混合活动内容是可以访问 HTTPS 页面的全部或部分文档对象模型的内容。这种类型的混合内容可以改变 HTTPS 页面的行为,并可能窃取用户的敏感数据。因此,除了上述混合显示内容的风险之外,混合活动内容还容易受到其他一些攻击媒介的影响。

在混合活动内容的情况下,中间人攻击者可以拦截对 HTTP 内容的请求。攻击者还可以重写响应以包含恶意 JavaScript 代码。恶意活动内容可以窃取用户的凭据、获取有关用户的敏感数据或尝试在用户的系统上安装恶意软件(例如,通过利用浏览器或其插件中的漏洞)。

混合内容涉及的风险确实取决于用户正在访问的网站类型以及暴露于该网站的数据的敏感程度。网页可能具有全世界可见的公共数据或仅在经过身份验证时可见的私有数据。如果网页是公开的并且没有有关用户的敏感数据,则使用混合活动内容仍然为攻击者提供了将用户重定向到其他 HTTP 页面并从这些站点窃取 HTTP cookie 的机会。

有用的文档链接

MDN - https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content

谷歌开发人员 - https://developers.google.com/web/fundamentals/security/prevent-mixed-content/what-is-mixed-content