如何解决检查 HSTS 预加载资格时出错
我设置了这个网站:
http://website1.com/ - 返回 301 Moved Permanently
并重定向到 http://www.website1.com/。
http://www.website1.com/ - 返回 301 Moved Permanently
并重定向到 https://www.website2.com/。
https://www.website2.com/ - 返回 200 OK
并在响应中包含此内容:
strict-transport-security: max-age=31536000; includeSubDomains
我有这个运行网络应用程序的子域: https://subdomain.website1.com/ 这在响应中还有以下标头:
Strict-Transport-Security: max-age=31536000; includeSubDomains
我希望为 website1.com/ 的所有子域提供预加载功能。 但是,我在检查 eligibility 时收到以下错误:
Error: No HSTS header
Response error: No HSTS header is present on the response.
Error: HTTP redirects to www first
http://website1.com (HTTP) should immediately redirect to https://website1.com (HTTPS) before adding the www subdomain.
Right Now,the first redirect is to http://www.website1.com/.
The extra redirect is required to ensure that any browser which supports HSTS will record the HSTS entry for the top level domain,not just the subdomain.
但是为什么重定向很重要?
我想要的只是让 http://subdomain.website1.com/ 内部重定向到 https://subdomain.website1.com/,以及让 http://website1.com/ 内部重定向到 https://website1.com/。
不能 http://website1.com 进行内部重定向到 https://website1.com,不管它重定向到 www.website1.com/ 的事实吗?
解决方法
我设置了这个网站:http://website1.com/ - 返回 301 Moved Permanently 并重定向到 http://www.website1.com/。
这是你的问题。 http://website1.com 应该重定向到 https://website1.com,然后重定向到 https://www.website1.com。
这样顶级 website1.com 域将获取 HSTS 标头并保护自身和所有子域(假设它具有 includeSubDomains
属性集 - 这是预加载的先决条件)。
如果不先切换到 HTTPS,或者直接跳到 https://www.website1.com,那么浏览器将永远不会在顶级域上看到 HSTS 标头,因此知道它(和所有子域)应该受 HSTS 保护.这 1) 安全性较低,2) 预加载时风险更大,因为您可能仍然拥有非 HTTPS 站点(例如 http://blog.website1.com 或 http://intranet.website1.com)。通过强制您在预加载之前进行设置,有望在仍然可以逆转 HSTS 时暴露这些问题(这在预加载到浏览器的源代码后基本上是不可能的 - 至少要持续数月)。
意外锁定带有预加载的非 HTTPS 子域的风险是一个原因 I’ve argued in the past that preload is potentially more risky than useful,并且对大多数网站来说都是过大的。但随着 HTTPS 成为常态,我现在不那么反对了。仍然认为它有点矫枉过正,除了高目标网站。
顺便说一句,对于第一个错误,请确保 301 重定向中包含 HSTS 标头。例如,对于 Apache,您需要 always set
而不仅仅是 set
,如下所述:https://stackoverflow.com/a/48103216/2144578
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。