【问题标题】:HSTS and access to subdomain with JavascriptHSTS 和使用 Javascript 访问子域
【发布时间】:2016-01-13 16:47:18
【问题描述】:

几周前,我将主页仅移至 https 并启用了 HSTS。在一个页面上,我有一些 JavaScript 代码通过 http 请求从子域获取其内容。在启用 https 之前,它运行良好。我还在javascript代码中将http协议更改为https。但这不是解决方案。

HTTPS 是限制对子域的访问还是 HSTS?

有没有办法允许访问子域?

这里是 JavaScript 代码:

<script type="text/javascript" src="/jquery-1.11.0.min.js"></script>
<script>
$("#ipv4").show().load('https://ipv4.mydomain.com/myip/'
, {limit: 25}, 
  function (responseText, textStatus, req) {
    if (textStatus == "error") {
      $("#ipv4").html("Kein IPv4");
    }
  }
);
$("#ipv6").show().load('https://ipv6.mydomain.com/myip/'
, {limit: 25}, 
  function (responseText, textStatus, req) {
    if (textStatus == "error") {
      $("#ipv6").html("Kein IPv6");
    }
  }
);
</script>

这是 HSTS-Header:

Strict-Transport-Security: max-age=31556926; includeSubDomains; preload

【问题讨论】:

  • 你的 HSTS 标头是什么?
  • 我在帖子中添加了 HSTS-header,子域也有有效的证书。
  • 因此 hst 适用于您的子域。 ssllabs 对它们有何评价?

标签: javascript https hsts


【解决方案1】:

HSTS 的唯一作用是在发送之前将 http 请求重写为 https。

因此,您的子域必须响应 https 请求才能正常工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-10
    • 1970-01-01
    • 2017-11-22
    • 1970-01-01
    相关资源
    最近更新 更多