Meet the HSTS preload requirements or remove preload on Apache
Why it matters
Your header asks browsers to preload the domain but the site does not meet the rules of the preload list. The preload list is very hard to leave once you are on it, so do not submit until you are sure.
Risky change. A wrong setting here can take your site or your mail offline. Follow the stages in order, test each one, and keep a way back.
The fix
- If the header does not include includeSubDomains yet, first follow the includeSubDomains fix (max-age=300, check every subdomain); use the full value only after that.
- Redirect http to https on the same host first, and send the full header on every HTTPS response of example.com, including its redirect to www if it has one. In this snippet example.com serves the site and www redirects to it; if it is the other way round, the redirecting example.com VirtualHost needs the Header line. Use Header always set everywhere, never a plain Header set elsewhere.
- SSL lines are omitted from the snippet. Keep the ones you already have.
- Run apachectl configtest and reload.
/ etc/ apache2/ sites-available/ site.conf
<VirtualHost *:80> ServerName example.com Redirect permanent / https://example.com/ </VirtualHost> <VirtualHost *:80> ServerName www.example.com Redirect permanent / https://www.example.com/ </VirtualHost> <VirtualHost *:443> ServerName example.com # SSLEngine, SSLCertificateFile and SSLCertificateKeyFile as usual Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" </VirtualHost> <VirtualHost *:443> ServerName www.example.com # SSLEngine, SSLCertificateFile and SSLCertificateKeyFile as usual Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" Redirect permanent / https://example.com/ </VirtualHost>
The examples use example.com. Replace it with your own domain.
Related
Scan your domain to see whether this applies to you.