HeaderScout

Check 01 · HSTS

HTTPS enforcement

Strict-Transport-Security

Strict-Transport-Security tells browsers to use HTTPS for your site every time, for as long as you say.

What it does

Without it, a visitor who types your address, uses an old bookmark or follows an http:// link sends one plain-HTTP request before your redirect takes them to HTTPS. Anyone on the same network can read or change that first request, and send the visitor somewhere else.

Once a browser has seen the header on an HTTPS response, it changes every http:// address for your domain to https:// before sending anything, for the next max-age seconds. Each visit starts the count again.

Browsers ignore the header on plain-HTTP responses, because anyone on the network could have added it there. While the rule is active, certificate errors on your site become hard errors: visitors can no longer click past the warning.

Parts of the value

PartMeaning
max-age=<seconds>How long the browser keeps the rule. Required. 0 tells the browser to forget it.
includeSubDomainsThe rule also covers every subdomain, including ones you may have forgotten about.
preloadSays you agree to have your domain built into browsers as HTTPS-only. Only has an effect after you apply for it, and is very slow to undo.

How we score it

20max-age of at least 15,552,000 seconds (180 days).
10A shorter, positive max-age.
0Missing, invalid (no or non-numeric max-age, a repeated directive), or max-age=0.

Only the first header on the final HTTPS response counts. includeSubDomains and preload are noted but not required. HSTS headers on redirects are shown for information.

All five checks and the grade scale: How grading works.

Examples

  1. Strict-Transport-Security: max-age=31536000

    20 / 20 · Strong One year. The usual value once HTTPS works everywhere on the domain.

  2. Strict-Transport-Security: max-age=31536000; includeSubDomains

    20 / 20 · Strong includeSubDomains is noted on the report but doesn't change the points.

  3. Strict-Transport-Security: max-age=2592000

    10 / 20 · Partial 30 days. Fine while you roll it out, but shorter than the 180 days needed for full points.

  4. Strict-Transport-Security: max-age=0

    0 / 20 · Weak Tells browsers to drop the rule. Useful to undo it, but it gives no protection.

  5. Strict-Transport-Security: includeSubDomains

    0 / 20 · Weak No max-age, so browsers ignore the whole header.

How to set it

Start with a short max-age, such as 300 seconds. Raise it to a week, then a month, then a year, checking that every page and asset loads over HTTPS at each step.

Send the header on every HTTPS response, not only the homepage. Browsers learn the rule from whichever page a visitor opens first.

Test first. Only send this once every page works over HTTPS. Browsers that see it refuse plain HTTP for the whole max-age, and you can't recall it early for visitors who already have it.

Strict-Transport-Security: max-age=31536000
Nginx

Put this in the server block. A location block with its own add_header lines doesn’t inherit these, so repeat them there.

add_header Strict-Transport-Security "max-age=31536000" always;
Apache

In the virtual host or .htaccess. Needs mod_headers (on Debian and Ubuntu: a2enmod headers).

Header always set Strict-Transport-Security "max-age=31536000"
Caddy

Inside your site block in the Caddyfile.

header Strict-Transport-Security "max-age=31536000"
Cloudflare

Rules → Create rule → Response Header Transform Rule. Apply to all incoming requests, choose “Set static”, and enter each header below.

Header name: Strict-Transport-Security
Value: max-age=31536000

Common mistakes

  • Sending the header only on the plain-HTTP redirect. Browsers ignore it there.
  • Two different headers, for example one from your server and one from your CDN. Browsers use the first, and so do we.
  • Adding includeSubDomains while an old subdomain (a mail web interface, an admin panel, a test site) still only works over plain HTTP. It stops loading for everyone who has the rule.
  • Adding preload as a formality. Once your domain is built into browsers, removing it takes months.

See what your site sends

One request to your homepage. Results are public.