Lawscan.org Scan free

Security

HTTP Security Headers Explained: HSTS, CSP, X-Frame-Options and More

Published October 2, 2026 · 6 min read

What the main HTTP security headers do, which ones every website should send, example values and how to add them on Apache, Nginx and WordPress.

Security headers are short instructions your server sends with every page, telling the browser how strictly to behave. They cost nothing, take minutes to add and block entire classes of attack. GDPR asks for "appropriate technical measures": these are some of the easiest visible ones.

Strict-Transport-Security (HSTS)

Forces browsers to use HTTPS for your domain. Example: Strict-Transport-Security: max-age=31536000; includeSubDomains. Enable it only when every subdomain works over HTTPS.

Content-Security-Policy (CSP)

Lists where scripts, styles, images and frames may be loaded from, which greatly limits cross-site scripting and data exfiltration. A starting point is default-src 'self', then allow only what you really use. It is the most powerful header and the one that needs testing.

X-Content-Type-Options

X-Content-Type-Options: nosniff stops browsers from guessing file types, preventing some script-injection tricks.

X-Frame-Options or frame-ancestors

X-Frame-Options: SAMEORIGIN (or the CSP directive frame-ancestors) prevents other sites from embedding yours in a frame, defeating clickjacking.

Referrer-Policy

Referrer-Policy: strict-origin-when-cross-origin limits how much of your URLs is leaked to other sites, which also helps privacy.

Permissions-Policy

Switches off browser features you do not use, such as camera, microphone or geolocation, so a compromised script cannot use them.

How to add them

  • Apache: Header always set ... in .htaccess (needs mod_headers).
  • Nginx: add_header ... always; in the server block.
  • WordPress: a security plugin or server-level configuration; avoid editing theme files.

Test and monitor

After changes, reload the site and watch the browser console for blocked resources. A Lawscan scan includes a technical snapshot of the security headers actually sent, with a suggested fix for each missing one.

Related checks in the Compliance Index

Find out what your website is missing

Scan it for free, then ask for a full report with a prioritised action plan.

Scan my website free

Prefer expert help? Request a full compliance report →

Keep reading

This guide is for general information and is not legal advice. Rules change and national laws vary: check with a qualified professional for your specific case.

Scan your website free →