Skip to content

Deploying HSTS on cPanel without painting yourself into a corner

How to roll out HTTP Strict Transport Security on a cPanel site safely — short max-age first, include subdomains only after audit, preload only when you mean it.

HSTS is one of those security headers where the wrong value is worse than no value. Set max-age=63072000; includeSubDomains; preload on day one and a customer site is locked to HTTPS for two years on every browser that has ever visited it — including subdomains you forgot existed. The careful rollout takes three weeks and ends in a better outcome.

What’s happening

HSTS is an HTTP response header (Strict-Transport-Security) that tells the browser to upgrade every future request for this host to HTTPS, for the duration of max-age. includeSubDomains extends the policy to every subdomain. preload opts the domain into the Chrome HSTS preload list, which is effectively permanent. The browser does not honor downgrades. If you ship HSTS and then later need to serve HTTP for a subdomain, you cannot.

How to verify

curl -I https://example.com/ | grep -i strict-transport
openssl s_client -connect example.com:443 < /dev/null 2>&1 | grep -i transport
grep -ri "Strict-Transport-Security" /home/<user>/public_html/.htaccess
dig +short example.com

If you see a Strict-Transport-Security header on the response, HSTS is already active. Note the max-age and whether includeSubDomains is present.

The fix

  1. Audit subdomains first: list every domain and subdomain on the account (whmapi1 fetch_domains user=<user>). If even one of them legitimately needs HTTP (an old IoT device, a partner integration), do not use includeSubDomains.
  2. Phase 1 (week 1): add Header always set Strict-Transport-Security "max-age=300" in the per-account .htaccess (or vhost include). Five minutes. Watch the site for issues — there should be none.
  3. Phase 2 (week 2): extend to max-age=86400 (one day). Confirm no customer complaints.
  4. Phase 3 (week 3): extend to max-age=31536000 (one year). At this point, browsers will refuse to load HTTP for a full year after each visit. No turning back without aging out the policy.
  5. includeSubDomains only after step 1’s audit confirms every subdomain serves HTTPS now and forever.
  6. preload only when you have confirmed step 5 and have submitted to hstspreload.org. Preload is effectively permanent.
  7. Document the policy in the customer-facing handover doc. Future operators must know HSTS is on; the alternative is a debugging mystery.

Stack Harbor deploys HSTS phased across managed accounts under WHM server management.