如果HSTS标头存在,为什么Chrome不会强制使用HTTPS?

问题描述 投票:2回答:1

如果我已经从我的服务器端启用了HSTS标头,那么为什么谷歌Chrome会忽略它?我可以用http自由访问网站。我期望浏览器应该强制网站只加载HTTPS。毕竟,HSTS就是为了这个目的。如果我错了,请纠正我。参考:Video

Connection:keep-alive
Content-Encoding:gzip
Content-Type:text/html; charset=UTF-8
Date:Mon, 18 Dec 2017 07:15:18 GMT
Link:<http://example.com/wp-json/>; rel="https://api.w.org/"
Server:nginx
Set-Cookie:wfvt_1954975060=5a376b06351b6; expires=Mon, 18-Dec-2017 07:45:18 GMT; Max-Age=1800; path=/; HttpOnly
Strict-Transport-Security:max-age=63072000; includeSubdomains;
Transfer-Encoding:chunked
Vary:Accept-Encoding
google-chrome security hsts
1个回答
2
投票

Strict-Transport-Security标头仅在HTTPS页面上有效。它在HTTP页面上被忽略 - 如果您想强制用户使用HTTPS,从所有HTTP页面将它们重定向到HTTPS,并在它们被重定向到的页面上显示Strict-Transport-Security标头。

MDN explains why

注意:使用HTTP访问您的站点时,浏览器会忽略Strict-Transport-Security标头;这是因为攻击者可能会拦截HTTP连接并注入标头或将其删除。当您的网站通过HTTPS访问而没有证书错误时,浏览器知道您的网站具有HTTPS功能并且将遵守Strict-Transport-Security标头。

© www.soinside.com 2019 - 2024. All rights reserved.