Every time your website loads, your server sends invisible instructions to the browser called HTTP headers. A handful of them are dedicated to security: they tell the browser to always use HTTPS, which scripts are allowed to run, whether your pages can be framed by other sites and what information to share when visitors click away.

They're cheap to add, they protect your visitors from common attacks, and many small business sites are missing most of them.

The headers that matter

HeaderProtects againstDifficulty
Strict-Transport-Security (HSTS)Downgrade to insecure HTTP, some interception attacksEasy
Content-Security-Policy (CSP)Cross-site scripting (XSS), injected scripts, data theftMedium–hard
X-Frame-Options / CSP frame-ancestorsClickjacking (your site hidden in someone else's frame)Easy
X-Content-Type-OptionsBrowsers guessing file types and running files as scriptsEasy
Referrer-PolicyLeaking full URLs (which may contain private data) to other sitesEasy
Permissions-PolicyUnwanted use of camera, microphone, location and other featuresEasy

Strict-Transport-Security (HSTS)

Tells browsers to only ever connect to your site over HTTPS, even if someone types http:// or clicks an old link.

A safe starting value:

Strict-Transport-Security: max-age=31536000; includeSubDomains

Only add includeSubDomains if every subdomain supports HTTPS. Once you're confident, you can add preload and submit your domain to the browser preload list, but removal from that list is slow, so be sure first.

Content-Security-Policy (CSP)

The most powerful header. It lists which sources of scripts, styles, images, fonts and connections are allowed. If an attacker manages to inject a script, the browser refuses to run it because it isn't on the list.

A simple starting point:

Content-Security-Policy: default-src 'self'; img-src 'self' data: https:; script-src 'self'; style-src 'self' 'unsafe-inline'; frame-ancestors 'self'; base-uri 'self'; form-action 'self'

Real sites usually need to add sources for analytics, payment providers, chat widgets, fonts and video embeds.

Roll it out safely

  1. Start with Content-Security-Policy-Report-Only, which reports violations without blocking anything.
  2. Collect reports for a week or two and add legitimate sources.
  3. Switch to enforcing mode.
  4. For stronger protection, use nonces or hashes for inline scripts instead of 'unsafe-inline'. Modern frameworks support nonce-based CSP.

Clickjacking protection

Stops other sites loading your pages in a hidden frame to trick users into clicking. Use the CSP directive:

Content-Security-Policy: frame-ancestors 'self'

and, for older browsers:

X-Frame-Options: SAMEORIGIN

X-Content-Type-Options

X-Content-Type-Options: nosniff

Stops browsers guessing file types, which prevents some attacks where uploaded files are treated as scripts. There's no reason not to set it.

Referrer-Policy

Controls what URL information is sent to other sites when visitors click a link or load external resources.

Referrer-Policy: strict-origin-when-cross-origin

This sends only your domain (not the full path) to other sites, which protects private details in URLs while keeping analytics useful. Most browsers now default to this, but setting it explicitly is good practice.

Permissions-Policy

Turns off powerful browser features your site doesn't use, so third-party scripts can't use them either:

Permissions-Policy: camera=(), microphone=(), geolocation=(), payment=()

Allow features you genuinely need, for example payment=(self) on a checkout.

A complete starter set

For a typical small business site that loads its own scripts plus Google Analytics, a starting set might look like this (adjust the CSP to the services you really use, and test in report-only mode first):

Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
Referrer-Policy: strict-origin-when-cross-origin
Permissions-Policy: camera=(), microphone=(), geolocation=()
X-Frame-Options: SAMEORIGIN
Content-Security-Policy: default-src 'self'; script-src 'self' https://www.googletagmanager.com; connect-src 'self' https://www.google-analytics.com https://*.google-analytics.com; img-src 'self' data: https:; style-src 'self' 'unsafe-inline'; font-src 'self'; frame-ancestors 'self'; base-uri 'self'; form-action 'self'

Each extra service (payment provider, chat widget, video embeds, booking tool) usually needs its domains added to the right CSP directives. The report-only phase tells you which.

Mistakes that break sites

  • Turning on HSTS preload before every subdomain supports HTTPS.
  • Copying a strict CSP from another site without adapting it, which blocks your analytics, payments or fonts.
  • Setting headers in two places (server and CDN) with different values.
  • Forgetting non-HTML responses such as API routes and file downloads when testing.
  • Blocking your own iframes, for example an embedded booking page on your own domain, with frame-ancestors 'none'.

How to add headers on common setups

SetupWhere
CloudflareRules → Transform Rules (modify response headers)
Nginxadd_header lines in the server block
ApacheHeader set lines in .htaccess or config
Caddyheader directive in the Caddyfile
Next.jsheaders() in next.config, or proxy for dynamic CSP with nonces
Shopify, Wix, SquarespaceLimited control; the platform sets several headers for you

Our guide to Cloudflare for small business websites covers setting headers at the edge.

How to check your headers

  • Open DevTools → Network, click the page request and look at Response Headers.
  • Run a free online security header scanner.
  • Our AI Website X-Ray checks security basics alongside SEO and speed.

Headers are one layer

Security headers don't replace keeping software updated, strong passwords and multi-factor authentication, backups and monitoring. Read website security basics for small business and website backup strategy. Certificate management matters too, as certificate lifetimes are getting much shorter. See SSL certificates and the 47-day rule.

The short version

Security headers instruct browsers to protect your visitors. Add HSTS, X-Content-Type-Options, Referrer-Policy, Permissions-Policy and clickjacking protection today: they're easy. Then roll out a Content-Security-Policy in report-only mode first, fix what it flags and enforce it.

Want your site hardened properly? Our maintenance and support team sets up headers, monitoring and updates for small business sites.