Guides · Security headers

Strict-Transport-Security (HSTS) header

One of the checks in every audibot report. This page says exactly what audibot reads, what passes, and how to fix it.

What audibot checks

The Strict-Transport-Security header on the HTTPS response of the home page, after following redirects, and the max-age it sets.

Why it matters

Without HSTS, a browser that is sent to http:// will make that plain request first, and someone on the same network can answer it instead of the site. HSTS tells the browser to use HTTPS for this host for max-age seconds without asking.

How do I add an HSTS header, and what max-age should it have?

Send the header on every HTTPS response. 31536000 (a year) is the usual value. Add includeSubDomains only once every subdomain serves HTTPS, because browsers will refuse plain HTTP on all of them.

nginx (inside the HTTPS server block)

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

Apache (mod_headers)

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

Caddy

example.com {
	header Strict-Transport-Security "max-age=31536000; includeSubDomains"
}

Cloudflare

SSL/TLS → Edge Certificates → HTTP Strict Transport Security (HSTS) → Enable,
with Max Age of 6 months or more.

Related tools

Other checks in Security headers

Security headers in the methodology ·All guides

This check is one step of the website launch checklist.

How often audited websites pass this check: see the website audit benchmarks, with sample size and denominators.

Check your site

audibot runs this check and every other one in a single audit, and publishes the report with a recommendation for each finding.