How to Fix Missing Security Headers (CSP, Referrer-Policy)

This check reads the HTTP response headers of your homepage and looks for three of them: Content-Security-Policy, X-Content-Type-Options and Referrer-Policy. If all three are missing the check fails, and if only one or two are missing it shows a warning. By the end of this guide you will have added all three at the server, framework or CDN level and confirmed them with a single command.

By Updated ⏱ 20–40 minutes🎯 Intermediate● Low impactTechnical
Illustration: Security headers fix guide
TECHNICAL · FIX GUIDE Security headers IMPACTEFFORT TIME20–40 minutes LEVELIntermediate

Why it matters

These headers don't directly change rankings, but they reduce real risk. X-Content-Type-Options stops browsers from MIME-sniffing a file into executable script. Referrer-Policy keeps full URLs, including query strings with emails or tokens, from leaking to third-party sites.

Content-Security-Policy limits clickjacking and, once tightened, script injection. A hacked or spam-injected site loses rankings and trust quickly. Security scanners, procurement reviews and some AI or crawler quality signals also treat missing headers as a sign of a poorly maintained site.

✕Beforecurl -sI https://example.com/ returnsonly content-type, cache-control andserver, with no CSP, nosniff or✓Aftercurl -sI https://example.com/ showscontent-security-policy:frame-ancestors 'self',

What you need

Access to your web server config (Nginx/Apache), framework config (Next.js) or CDN dashboard (Cloudflare, Netlify, Vercel)
A terminal with curl, or browser DevTools
Permission to reload the web server or redeploy the site
A staging URL to test on first (recommended)

Step-by-step fix

1

Check which headers your homepage sends now

Request only the headers of your homepage and note which of the three are missing. Use the final URL visitors land on (for example https://www.example.com/ if the bare domain redirects there). The headers must exist on that final 200 response, not just on the redirect.

text
curl -sIL https://example.com/ | grep -iE 'content-security-policy|x-content-type-options|referrer-policy'
Pro tip: If you have no terminal, open DevTools (F12) > Network, reload, click the first document request and read the Response Headers panel.
2

Choose safe starting values for all three headers

Start with values that won't break anything:

  • X-Content-Type-Options: nosniff is the only valid value.
  • Referrer-Policy: strict-origin-when-cross-origin sends only the origin to other sites and keeps analytics referrals working.
  • Content-Security-Policy: frame-ancestors 'self' blocks other sites from framing yours. It does not restrict scripts, styles or images, so it can't break your tracking tags or widgets.

A full script-restricting CSP comes later (step 7).

Pro tip: Content-Security-Policy-Report-Only is a different header name and does not satisfy this check. You need the enforcing Content-Security-Policy header.
3

Add the headers on Nginx

conf. Put the lines in the HTTPS server { } block. The always flag also sends them on error and redirect responses.

Test the config, then reload Nginx.

nginx
server {
    listen 443 ssl;
    server_name example.com www.example.com;

    add_header X-Content-Type-Options "nosniff" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;
    add_header Content-Security-Policy "frame-ancestors 'self'" always;

    # ...rest of config
}

# then run:
# sudo nginx -t && sudo systemctl reload nginx
Pro tip: Nginx drops server-level add_header lines inside any location { } block that has its own add_header. If your homepage is served from such a block, repeat the three lines there or move them into a shared include file.
4

Or add them on Apache via .htaccess

On Apache or LiteSpeed hosting (common for WordPress), add this to the .htaccess file in your site root, above the WordPress rewrite block. It requires mod_headers, which most hosts enable. If you see a 500 error afterwards, ask your host to enable mod_headers.

apache
<IfModule mod_headers.c>
    Header always set X-Content-Type-Options "nosniff"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
    Header always set Content-Security-Policy "frame-ancestors 'self'"
</IfModule>
Pro tip: Use "set" rather than "append" so you don't create duplicate values if a plugin or the host already sends one of these headers.
5

Or set them in Next.js (self-hosted or Vercel)

js, add an async headers() function that applies to every path. This works on Vercel and on self-hosted next start. json or your host's header config instead.

Redeploy afterwards.

javascript
// next.config.js
module.exports = {
  async headers() {
    return [
      {
        source: '/:path*',
        headers: [
          { key: 'X-Content-Type-Options', value: 'nosniff' },
          { key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },
          { key: 'Content-Security-Policy', value: "frame-ancestors 'self'" },
        ],
      },
    ];
  },
};
Pro tip: If you use Next.js middleware to generate a nonce-based CSP, set the header there and remove the static CSP so you don't send two.
6

Or add them at the CDN if you can't touch the server

On Cloudflare, go to Rules > Overview > Create rule > Response Header Transform Rule. Match all incoming requests for your hostname, then add three Set static operations, one per header. Netlify reads a _headers file in your publish directory using the format below.

After saving, purge the CDN cache so the homepage is served with the new headers.

text
# Netlify: _headers file in publish directory
/*
  X-Content-Type-Options: nosniff
  Referrer-Policy: strict-origin-when-cross-origin
  Content-Security-Policy: frame-ancestors 'self'
Pro tip: Cloudflare's Managed Transform 'Add security headers' sets X-Content-Type-Options and a Referrer-Policy but no CSP, so you still need a transform rule for Content-Security-Policy.
7

Tighten the CSP gradually (optional)

Once the basic header passes, you can build a stronger policy. Add a Content-Security-Policy-Report-Only header with a stricter policy next to the enforcing one. Watch the browser console or your report endpoint for a week, and add every legitimate source you find (analytics, tag manager, payment, chat widgets).

Only then move those directives into the enforcing header.

text
Content-Security-Policy-Report-Only: default-src 'self'; script-src 'self' https://www.googletagmanager.com; img-src 'self' data: https:; style-src 'self' 'unsafe-inline'; frame-ancestors 'self'; report-to csp
Pro tip: Never replace the enforcing header with a Report-Only one. The check would go back to reporting content-security-policy as missing.
8

Verify the headers on the live homepage

Run the curl command from step 1 again against the final homepage URL. Confirm that all three header names appear exactly once, with the values you set. Then re-run the audit; the check should show CSP, X-Content-Type-Options and Referrer-Policy as set.

text
curl -sIL https://example.com/ | grep -iE 'content-security-policy|x-content-type-options|referrer-policy'

# expected:
# content-security-policy: frame-ancestors 'self'
# x-content-type-options: nosniff
# referrer-policy: strict-origin-when-cross-origin
Pro tip: Add a cache-busting query string (https://example.com/?v=2) if a CDN may still be serving an old cached response.

Platform-specific notes

WordPress

Use .htaccess on Apache/LiteSpeed hosts or the Nginx server block on Nginx hosts. On managed hosts without file access (for example WP Engine or Kinsta), add the headers through the host dashboard or a support ticket. A plugin such as 'Headers Security Advanced & HSTS WP' also works, because it sends real HTTP headers through PHP. Note that cached pages served by the host may bypass it, so verify with curl.

Shopify

You can't edit storefront HTTP response headers in Shopify. Theme code can only add meta tags, and those don't count as headers. Shopify already sends X-Content-Type-Options and a Content-Security-Policy on storefronts. If the check still lists a missing header, accept the warning or contact Shopify Support. Putting your own proxy in front of Shopify is not supported.

Wix and Squarespace

Both platforms control response headers and don't let site owners add custom ones. Check what they already send with curl. A remaining warning here can't be fixed from the site editor.

Webflow

Standard Webflow hosting doesn't support custom response headers. Options are Enterprise hosting, or serving the site through Cloudflare (proxied DNS) and adding a Response Header Transform Rule.

Cloudflare

Response Header Transform Rules apply to every proxied response, including cached ones, so they work for any origin platform as long as the DNS record is proxied (orange cloud). Rules don't apply to DNS-only records.

Check that it worked

✅ How to verify

  • Run curl -sIL https://example.com/ and confirm content-security-policy, x-content-type-options and referrer-policy each appear on the final 200 response.
  • In Chrome DevTools > Network, select the homepage document and check the three headers under Response Headers.
  • Paste the URL into securityheaders.com and confirm all three are listed as present.
  • Re-run the audit and confirm the Security headers check has moved from fail or warn to pass.

⚠️ Common mistakes

  • Adding a <meta http-equiv="Content-Security-Policy"> or <meta name="referrer"> tag instead of a real HTTP header. The check only reads response headers, and browsers ignore frame-ancestors in meta CSP.
  • Sending only Content-Security-Policy-Report-Only, which is a different header and doesn't count as CSP.
  • Adding the headers in an Nginx location block or on the non-www host while the homepage is served elsewhere, so the final homepage response still lacks them.
  • Copying a strict CSP (default-src 'self') from another site and enforcing it immediately, which blocks analytics, tag managers, fonts and payment scripts.

Is this still an issue on your site? Run a free audit — ZORO checks this and 294 other SEO, AI-visibility, accessibility and security signals, with fixes for your platform.

Check my site free

FAQ

Will adding a Content-Security-Policy break my website?

Not with frame-ancestors 'self'. That value only controls who can embed your site in a frame, and it leaves scripts, styles and images alone. Breakage comes from script-src or default-src restrictions, so test those in Report-Only mode first.

Do security headers affect SEO rankings?

Not directly; Google doesn't use them as a ranking factor. They lower the chance of hacks, spam injection and data leaks, and those problems can cause manual actions, browser warnings and lost traffic.

Which Referrer-Policy value should I use?

strict-origin-when-cross-origin is the browser default and the safest general choice. Analytics still sees which domain sent a visitor, but full paths and query strings aren't shared with other sites. Use no-referrer only if you don't need referral data.

Do I need X-Frame-Options if I set frame-ancestors?

Modern browsers prefer CSP frame-ancestors and ignore X-Frame-Options when both are present. Adding X-Frame-Options: SAMEORIGIN for very old browsers is harmless, but this check doesn't require it.