This is the third article in a four-part series about HTTP security headers and Drupal: what they are, why you should care, and how to implement them to increase the security of your Drupal site. In this entry, I will be covering how to implement the Strict Transport Security, X Content Type Options, and X Frame Options headers. I’ll be relying on the groundwork laid out in Part 1, so if you haven’t read that yet, there’s a link to it below.
- Part 1: Introduction
- Part 2: Permissions Policy
- Part 4: Content Security Policy
Strict Transport Security
HTTP Strict Transport Security (HSTS) strengthens your implementation of SSL/TLS by getting the User Agent to enforce the use of HTTPS. It forces a user's browser to connect to your site via HTTPS and converts any HTTP links to HTTPS before sending a response.
The Security Kit module provides an easy way to implement this header. Under the SSL/TLS dropdown on the module configuration page will be a toggle and options for this header. Toggle it on to enable. The Max-Age setting sets how long (in seconds) the browser’s user agent will cache the header before fetching it again on the next request. If your site contains subdomains, toggle the Include Subdomains option as well.