在我的内部网站中添加 HTST header 没有按预期工作

Adding HTST header in my internal website doesn't work as expected

我创建了一个网站,我试图通过 httpd.conf

添加 HSTS 安全性 header
<IfModule mod_headers.c>
Header always set Strict-Transport-Security 'max-age=4000; includeSubDomains'
</IfModule>

添加上面的代码,可以看到 Strict-Transport-Security header 添加到我的 HTTPS 响应 header

host> curl -v https://172.21.218.67 --insecure
* About to connect() to 172.21.218.67 port 443 (#0)
*   Trying 172.21.218.67... connected
* Connected to 172.21.218.67 (172.21.218.67) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* warning: ignoring value of ssl.verifyhost
* skipping SSL peer certificate verification
* SSL connection using TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
* Server certificate:
*       subject: ****************************************
*       start date: Oct 21 06:42:49 2019 GMT
*       expire date: Nov 20 06:42:49 2019 GMT
*       common name: Insights
*       issuer: *****************************************
> GET / HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 172.21.218.67
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Mon, 21 Oct 2019 10:50:54 GMT
< Server: Apache
< Strict-Transport-Security: max-age=4000; includeSubDomains
< Last-Modified: Mon, 21 Oct 2019 08:58:58 GMT
< ETag: "8f3-59567e4f07362"
< Accept-Ranges: bytes
< Content-Length: 2291
< Content-Type: text/html

但这确实会通过浏览器对我的网站产生影响。 (如果用户尝试通过 HTTP 访问我的网站,浏览器不会重定向到 HTTPS)。

我什至无法在 chrome 的 HSTS 清单中看到我的网站列表

chrome://net-internals/#hsts

我是否需要添加任何其他配置才能使其正常工作?

根据 IMSoP 的建议,我的测试服务器不受影响 HSTS 功能的服务器的信任。

已解决: 通过添加自签名证书使我的测试服务器成为浏览器的可信来源。 现在 HSTS 按预期工作。