Search code examples
google-chromesecurityhttpd.confhsts

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


I have created a website where I am trying to add the HSTS security header via httpd.conf

<IfModule mod_headers.c>
Header always set Strict-Transport-Security 'max-age=4000; includeSubDomains'
</IfModule>

Adding the above code, able to see the Strict-Transport-Security header added over my HTTPS response 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

But this does create an impact over my website by the browser. (Browser is not redirecting to HTTPS if the user tries to access my website via HTTP).

I could not even see my website listing in chrome's HSTS checklist

chrome://net-internals/#hsts

Do I need to add any other configuration in order to make it work?


Solution

  • As suggested by IMSoP, my test server was not trusted by the server which affected the HSTS functionality.

    Solved: Made my test server as a trusted source to the browser by adding a self-signed certificate. Now the HSTS working as expected.