❤️
SecurityHeaders.nl

HTTP Strict Transport Security (HSTS)

The Strict-Transport-Security (HSTS) header tells the browser that the website should only be accessed using HTTPS, instead of using HTTP.

Why HSTS is Important

Even if you redirect all HTTP traffic to HTTPS on your server, the initial HTTP request is still vulnerable to a Man-in-the-Middle (MitM) attack, such as SSL stripping. An attacker can intercept the initial HTTP request and prevent the user from ever reaching the secure HTTPS version of your site.

By issuing the HSTS header, you instruct the browser to remember (for a specified period of time) that it should automatically convert any future HTTP requests to your site into HTTPS requests before they even leave the browser.

Best Practice Configuration

Strict-Transport-Security: max-age=31536000; includeSubDomains; preload

Let's break down these directives:

Warning

Do not include the preload directive unless you are absolutely certain that you can support HTTPS for your entire domain and all its subdomains indefinitely. Once you are on the preload list, it is difficult to be removed, and any subdomain without a valid SSL certificate will become inaccessible.