Beamfar

How to roll out HSTS preload and HTTP-to-HTTPS 301 redirects without breaking subdomains

Serving a site over HTTPS with a valid certificate solves only half of transport security. Whenever a returning visitor types your bare domain into an address bar, clicks an older plain http:// link, or connects over public Wi-Fi, their browser makes an unencrypted initial request to port 80 unless it already knows your domain is HTTPS-only. An attacker on a shared network can intercept that very first plain HTTP request and strip the upgrade to HTTPS before TLS ever begins.

HTTP Strict Transport Security (HSTS), defined in RFC 6797, eliminates that window by instructing browsers to rewrite every future connection for your host to https:// internally before a single packet leaves the device. Submitting your domain to the HSTS Preload List (hstspreload.org) closes even the very first visit by baking that HTTPS-only rule directly into Chrome, Firefox, Safari and Edge binaries.

Done carefully, HSTS preloading is one of the highest-leverage transport hardening steps a web team or agency can ship. Done carelessly — by pasting includeSubDomains; preload on day one without auditing staging, mail or internal subdomains — it can lock browsers out of legacy hosts for months.

What hstspreload.org actually requires (and why teams get rejected)

Many teams add a basic Strict-Transport-Security: max-age=31536000 header and assume they are done, only to fail preload validation or miss subtle redirect flaws. According to the Chromium HSTS Preload requirements, a domain must satisfy every single rule below simultaneously:

  1. Valid TLS certificate on the apex domain and every subdomain: Self-signed, expired or hostname-mismatched certificates cause hard non-bypassable browser errors once HSTS is active.
  2. Redirect plain http:// to https:// on the same host first: If your canonical site is https://www.example.com, port 80 on http://example.com must redirect to https://example.com first, and only then redirect https://example.com to https://www.example.com. Jumping directly from http://example.com to https://www.example.com skips the HTTPS apex response, so browsers never receive the apex Strict-Transport-Security header.
  3. Permanent redirect status (301 or 308): Temporary 302 or 307 redirects signal to crawlers and browsers that HTTP enforcement may change. Use 301 Moved Permanently (or 308 Permanent Redirect for APIs that must preserve POST bodies).
  4. Serve all subdomains over HTTPS: Including www, staging, dev, mail, webmail, portal, marketing microsites, and internal tools reachable on your corporate DNS zone.
  5. Send the full preload-eligible header on the HTTPS apex response:

- max-age of at least 31536000 seconds (one full year; two years, 63072000, is the standard production target). - The includeSubDomains directive. - The preload directive.

  1. Never emit Strict-Transport-Security over plain HTTP: Per RFC 6797, browsers strictly ignore HSTS headers received on unencrypted http:// responses; sending the header only on https:// server blocks keeps configurations unambiguous.

Check it now. The HSTS preload & HTTPS enforcement checker checks Strict-Transport-Security max-age, includeSubDomains and preload eligibility, verifies plain http:// to https:// permanent 301/308 redirects, and tests TLS 1.2/1.3 and legacy TLS 1.0/1.1 rejection; the security headers checker reads a page’s HSTS, CSP, X-Content-Type-Options, frame protection, Referrer-Policy and Permissions-Policy. No account, and the address is not stored.

The four-stage safe rollout sequence

Never enable max-age=63072000; includeSubDomains; preload on an unaudited production domain in one jump. Removing a domain from browser preload lists requires waiting for browser release cycles, which takes months across Chrome, Safari, Edge and Firefox. Follow a calm four-stage ramp instead:

  1. Stage 1 — Inventory every DNS subdomain first: Export the full DNS zone from Cloudflare, Route 53, Hetzner DNS or cPanel and check every A, AAAA and CNAME host for valid HTTPS. Pay close attention to forgotten client portals, staging environments, Matomo or newsletter tracking subdomains, and third-party SaaS CNAMEs.
  2. Stage 2 — Five-minute canary (max-age=300): Ship Strict-Transport-Security: max-age=300; includeSubDomains and test your primary site, checkout, admin panels and subdomains across browsers. If an unencrypted legacy subdomain breaks, revert the header or set max-age=0 and wait five minutes for browsers to clear it.
  3. Stage 3 — One-week to one-month soak (max-age=604800 then max-age=2592000): Run for at least one full billing, reporting and deployment cycle so seasonal cron dashboards, partner portals and client editors confirm HTTPS works everywhere without warnings.
  4. Stage 4 — Full preload commitment (max-age=63072000; includeSubDomains; preload): Once every subdomain passes cleanly and port 80 redirects permanently to HTTPS on hop 1, publish the full two-year header and verify your domain on hstspreload.org.

Copy-paste server configurations (Nginx, Apache, Cloudflare)

Nginx (server blocks for port 80 and port 443)

# Port 80: permanent same-host upgrade to HTTPS
server {
  listen 80;
  listen [::]:80;
  server_name example.com www.example.com;
  return 301 https://$host$request_uri;
}

# Port 443: modern TLS + preload-ready HSTS on every response (including 4xx/5xx)
server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  server_name example.com www.example.com;

  ssl_protocols TLSv1.2 TLSv1.3;
  add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
}

Notice the always parameter in Nginx add_header. Without always, Nginx omits Strict-Transport-Security on 301, 302, 404 and 500 responses — which causes hstspreload.org validation to fail whenever your apex domain redirects https://example.com to https://www.example.com.

Apache (.htaccess or VirtualHost)

# Enforce permanent HTTPS upgrade on port 80
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# Send HSTS only on HTTPS responses
<IfModule mod_headers.c>
  Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" env=HTTPS
</IfModule>

Cloudflare edge settings

When Cloudflare proxies your domain, configure two settings inside SSL/TLS &rarr; Edge Certificates:

  • Enable Always Use HTTPS so Cloudflare upgrades port 80 requests with a 301 redirect at the edge.
  • Configure HTTP Strict Transport Security (HSTS) with Max Age = 12 months (or custom header for 24 months), Apply HSTS policy to subdomains, and Preload only after completing Stage 1–3 above.
  • Set Minimum TLS Version to TLS 1.2 so deprecated TLS 1.0 and TLS 1.1 handshakes are refused in accordance with RFC 8996.

Common production regressions after enabling HSTS

Even mature engineering teams break HSTS months after launch during routine infrastructure changes:

  • Nginx nested add_header inheritance traps: Adding a single add_header Cache-Control ...; inside a location block silently drops every add_header inherited from the parent server block — including Strict-Transport-Security. Always verify headers on both / and key subpaths after editing Nginx configs.
  • CDN or proxy migrations dropping edge headers: Moving DNS off Cloudflare or switching reverse proxies resets edge-injected HSTS unless the origin web server also emits the header.
  • Expiring certificates becoming hard outages: Without HSTS, a visitor might click through a browser warning in an emergency. With HSTS active, browsers remove the bypass button completely — making early certificate expiry alerts (30, 14 and 7 days before expiry) non-negotiable.
  • Legacy TLS 1.0 or TLS 1.1 creeping back on load balancers: Default listener profiles on new cloud load balancers or hosting panels occasionally enable TLS 1.0/1.1 unless explicitly locked to TLS 1.2 and TLS 1.3.

Quick curl verification commands

# 1. Verify port 80 sends a permanent 301/308 redirect straight to https://
curl -sSI http://example.com/ | grep -iE '^(HTTP/|location:)'

# 2. Verify HTTPS apex sends Strict-Transport-Security (even when redirecting to www)
curl -sSI https://example.com/ | grep -iE '^(HTTP/|location:|strict-transport-security:)'

How Beamfar helps

Check any public domain right now with zero login using the free, zero-storage HSTS preload &amp; HTTPS enforcement checker. It inspects Strict-Transport-Security against RFC 6797 and hstspreload.org directives, traces port 80 redirection, and verifies TLS certificate health and legacy TLS 1.0/1.1 refusal in one pass with copy-paste Nginx, Apache, Cloudflare and staged rollout snippets. Pair it with our security headers checker and SSL certificate checker, or add your domains to Beamfar for continuous two-region EU uptime, early TLS expiry alerts and daily external security header drift detection.

Sources

Read on . Standards and vendor pages change; confirm the current text before you rely on it.

Terms used in this guide

  • HSTSHSTS is a response header telling browsers to use only HTTPS for a site. What max-age and includeSubDomains do, and why an expired certificate then hurts.
  • TLS certificateA TLS certificate proves a website holds the name in the address bar and enables HTTPS. What it contains, how long it lasts, what expiry breaks.
  • RedirectA redirect is an HTTP response that sends a visitor or crawler to another URL. The permanent and temporary status codes and how Google treats each.
  • Redirect chainA redirect chain is a sequence of redirects between the first URL and the final page. How many hops Google follows and why to collapse chains to a single hop.

Try it on your own sites.

Add your sites: checking starts as soon as you do.

No card for the Free plan.