ssl-guides 2026-12-02 ⏱ 3 min read

Audit HSTS, CSP and Security Headers

Audit HSTS, CSP and Security Headers

HTTPS encrypts the connection, but HSTS, CSP and the other security headers decide what the browser is allowed to do once the page loads. A site with a valid certificate and no headers still accepts injected scripts, clickjacking frames and downgrade attempts.

Start by looking at what your server actually sends. The Security Headers scanner reads the live response and lists what is missing; from a terminal, curl -sI https://example.com does the same.

The HSTS, CSP and security headers worth setting

HeaderProduction valueBlocks
Strict-Transport-Securitymax-age=31536000; includeSubDomainsSSL stripping and downgrade
Content-Security-Policydefault-src 'self'; upgrade-insecure-requests; frame-ancestors 'self'Injected scripts and framing
X-Content-Type-OptionsnosniffMIME sniffing exploits
Referrer-Policystrict-origin-when-cross-originReferrer leakage
Permissions-Policycamera=(), microphone=(), geolocation=()Silent sensor access

X-Frame-Options is still worth sending as SAMEORIGIN for older browsers, even though frame-ancestors in CSP supersedes it.

Nginx configuration that survives a config review

add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
add_header Content-Security-Policy "default-src 'self'; upgrade-insecure-requests; frame-ancestors 'self'" always;

The always flag matters: without it Nginx omits the header on error responses, which is exactly when a header can help. The other trap is inheritance. A nested location block that declares its own add_header drops every add_header from the parent, so a header you set at server level disappears on one path. Use include files or repeat the headers in each block.

Apache and LiteSpeed

<IfModule mod_headers.c>
  Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
  Header always set X-Content-Type-Options "nosniff"
  Header always set Referrer-Policy "strict-origin-when-cross-origin"
  Header always set Content-Security-Policy "default-src 'self'; upgrade-insecure-requests; frame-ancestors 'self'"
</IfModule>

Roll out CSP without breaking the site

  1. Deploy Content-Security-Policy-Report-Only with the policy you intend to use. Nothing is blocked; violations are reported.
  2. Read the reports for a week. Third-party analytics, fonts, payment iframes and inline scripts show up here.
  3. Add the required sources, or move inline scripts into files with nonces.
  4. Switch the header name to Content-Security-Policy, keeping the same value.
  5. Re-test checkout and any embedded form, because those are the paths that break first.

upgrade-insecure-requests is the safest first directive. It tells the browser to fetch http:// subresources over https://, which fixes most mixed content while you clean the source. It does not help on browsers older than about 2017.

HSTS: strong, and hard to undo

HSTS tells the browser to refuse plain HTTP for your domain for the duration in max-age. Add includeSubDomains only when every subdomain, including internal and staging names, serves HTTPS. Add preload only when you are prepared to wait months for removal from the browser list.

A common incident: HSTS with includeSubDomains is set on example.com, and a forgotten staging subdomain on plain HTTP becomes unreachable for every returning visitor. Test every subdomain with the SSL Checker before you add includeSubDomains.

HSTS, CSP and security headers: check behaviour, not the grade

A scanner grades the headers it can see. It cannot tell you that your checkout loads a script from a third-party domain that CSP will block. After deploying, load the cart, checkout, login and a content page with the console open, and confirm nothing was refused.

Two more checks worth running: the HTTPS redirect generator to confirm a single 301 hop rather than a chain, and the TLS checker to confirm 1.3 is actually negotiated.

Related reading: how to enable HSTS and whether AI search engines penalize HTTP sites.

Frequently Asked Questions

Do security headers affect SEO?

Indirectly. Headers prevent injected content, malware flags and duplicate HTTP indexing, all of which hurt visibility. The headers themselves are not a ranking factor.

Can I set HSTS on a domain that still has HTTP-only pages?

No. Once HSTS is set, those pages become unreachable for returning visitors. Convert them first, or set a short max-age while you migrate.

Why is my header missing on error pages?

Because it was added without the always flag, or a nested location block redefined add_header and dropped the inherited set.

Should I preload HSTS on a new site?

Not early. Preload commits every subdomain to HTTPS for months, and removal from the browser list is slow. Get every subdomain working first.

🛡️ Scan Your Site for Mixed Content & Security Headers
Scan Security Headers →

✅ Post-Installation Verification & SEO Checklist

After applying the steps above, run through this 5-point checklist to prevent browser warnings and protect your Google SEO rankings:

  • Verify full CA chain trust and TLS 1.3 support using our Live SSL Checker.
  • Scan for Mixed Content HTTP links and check HSTS/CSP headers on Security Headers Checker.
  • Enforce a permanent 301 HTTP-to-HTTPS redirect with our HTTPS Redirect Generator.
  • Confirm both root and www versions resolve cleanly to one canonical HTTPS URL.
  • Verify your HTTPS property and sitemap.xml inside Google Search Console and Bing Webmaster Tools.
Technically Reviewed by TryFreeSSL Security Team
Last updated: 2026-12-05
About Us →

Free SSL Certificates, Live SSL Checker & CSR Generator

Issue trusted Let's Encrypt SSL certificates in 60 seconds with zero server setup.

Related Articles

🤖 TryFreeSSL AI Assistant