Re-enable HSTS (max-age is zero) on Caddy
Why it matters
A max-age of zero tells browsers to forget HSTS, so the site is sending the header but gaining no protection from it. It is often left over from a rollback.
Staged change. Do this in stages and check each one before the next, so a mistake does not break your site or your mail.
The fix
- Find the header line that sets max-age=0 in the Caddyfile and change it, then reload Caddy.
- Raise max-age in the stages from the generic steps (86400, then 2592000, then 31536000), reloading and checking with curl -sI each time.
Caddyfile
example.com { header Strict-Transport-Security "max-age=300" }
The examples use example.com. Replace it with your own domain.
Related
- Reported by the HSTS check
- Add the Strict-Transport-Security (HSTS) header
- Fix the malformed Strict-Transport-Security header
- Raise the HSTS max-age
- Decide whether to add includeSubDomains
- Meet the HSTS preload requirements or remove preload
- Consider submitting the domain to the HSTS preload list
- Send HSTS on the redirect visitors meet first
Scan your domain to see whether this applies to you.