大网数据广告活动
服务器运维问答

HSTS: Is includeSubDomains on main domain sufficient?

· 52CE 我爱测

In my Plesk web admin edition I just activated HSTS on my main domain www.domain.tld with add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; The test on ssllabs.com says that everything works fine.…

问题原文

原帖链接 · Sr. Schneider · CC BY-SA 4.0

In my Plesk web admin edition I just activated HSTS on my main domain www.domain.tld with

add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

The test on ssllabs.com says that everything works fine. The problem is my subdomain (subdomain.domain.tld). If I test my subdomain on ssllabs it says that there is no HSTS activated.

Should I include the header

add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

on my subdomain too or is an implementation on my main domain sufficient?

I thought by adding includeSubDomains there was no need for adding it explicitly on subdomains.

已采纳解答

原帖链接 · dannosaur · CC BY-SA 4.0

The includeSubDomains part only instructs the browser, once its seen it, that requests to other sub-domains should abide by the same HSTS rules (i.e; a valid certificate must be present). It doesn't "infer" the application of this rule to your sub-domains, if for instance a user has never accessed your www.domain.tld site before. In this case, their browser will never have seen the presence of this header on your www sub-domain, and thus will not apply HSTS rules.

If a user has seen this header on your www sub-domain, then tries to access a sub-domain with an invalid certificate, it will block it and prevent the user from continuing.

In short, you need to ensure that you serve the same HSTS header across all your sub-domains in order for this to be 100% effective.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-08-21)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。