如何从安全 (HTTPS) 页面访问本地不安全 (HTTP) 服务器

How To Reach Local Insecure (HTTP) Server From A Secure (HTTPS) Page

本文关键字:不安全 服务器 HTTP 访问 安全 HTTPS      更新时间:2023-09-26

我有一个在https上运行的网站,它试图通过AJAX访问作为http服务器运行的Windows服务,使用http localhost地址。 但是,这将返回"访问被拒绝"错误。 从 http 调用时它工作正常,但这不是测试之外的选项。 我们也仅限于使用 Internet Explorer (9+)。

我已将相应区域的"允许混合内容"安全设置设置为"启用",但它仍然被阻止。

AJAX 调用如下所示:

    $.ajax({
        url: 'http://localhost:5923/somefunction',
        data: {
            sid: sid,
            aid: aid
        },
        success: function (ret) {
            //...
        },
        error: function (error, status, errThrown) {
            alert(errThrown);
        }
   });

我知道修改 Windows 服务以通过 https 运行是长期的最佳解决方案,但是有没有人对允许混合活动内容的 IE 设置或任何其他临时修复有任何建议?

提前谢谢。

您需要

启用跨域访问,因此请转到工具->Internet选项->安全选项卡,单击所选区域的"自定义级别"按钮。转到杂项 ->跨域访问数据源设置,然后选择"启用"选项。

此代码是否被 SOP(同源策略)阻止?如果是这样,请将"跨域"设置设置为"true"。http://api.jquery.com/jquery.ajax/