How to Fix Missing Clickjacking Protection (frame-ancestors)
Clickjacking happens when another site loads your page inside an invisible iframe and tricks visitors into clicking buttons they cannot see, such as Buy, Delete or Log in. By the end of this guide your homepage, and the rest of your site, will send an HTTP response header that tells browsers only your own domain may frame it.

Why it matters
Without a frame-ancestors rule or X-Frame-Options header, any site can embed your login, checkout or account pages and overlay fake UI on top of them. That can lead to unwanted purchases, changed settings or stolen sessions. It can also let scraper or spam sites show your content inside their own pages.
Security scanners, procurement questionnaires and browser security audits flag this header as missing. The fix is one or two lines of server config and has no effect on rankings or page speed.
What you need
Step-by-step fix
Check which headers your homepage sends now
Request your homepage and look at the response headers. You pass if either of these is present:
- X-Frame-Options with the value DENY or SAMEORIGIN
- A Content-Security-Policy header that contains a frame-ancestors directive
X-Frame-Options: ALLOW-FROM does not count, and modern browsers ignore it. A Content-Security-Policy-Report-Only header does not count either. Follow redirects so you test the final URL.
curl -sIL https://example.com | grep -iE 'x-frame-options|content-security-policy'
Choose the right framing policy
Pick one value for frame-ancestors:
- 'self' lets only pages on your own origin frame the site. This is the safe default for most sites.
- 'none' blocks all framing, including your own.
- 'self' https://partner.example.com allows specific trusted origins as well.
Pair it with X-Frame-Options: SAMEORIGIN (or DENY) as a fallback for very old browsers. When both headers are present, modern browsers follow frame-ancestors.
Content-Security-Policy: frame-ancestors 'self' https://partner.example.com X-Frame-Options: SAMEORIGIN
Add the headers on Nginx
Put these lines inside the server { } block that serves your HTTPS site, or inside a specific location { } block. The always flag makes Nginx send the headers on error and redirect responses too. One catch: if a location block has its own add_header lines, it does not inherit headers from the server block, so repeat the lines there.
Test the config and reload Nginx.
add_header Content-Security-Policy "frame-ancestors 'self'" always; add_header X-Frame-Options "SAMEORIGIN" always; # then run: # sudo nginx -t && sudo systemctl reload nginx
Or add them on Apache / .htaccess
On Apache, mod_headers must be enabled. On Debian/Ubuntu run sudo a2enmod headers. htaccess file in your web root.
Using always also covers redirect and error responses.
<IfModule mod_headers.c> Header always set Content-Security-Policy "frame-ancestors 'self'" Header always set X-Frame-Options "SAMEORIGIN" </IfModule>
Or set them in Next.js / Vercel
js. This works on any host. *).
Redeploy afterwards.
// next.config.js
module.exports = {
async headers() {
return [
{
source: '/(.*)',
headers: [
{ key: 'Content-Security-Policy', value: "frame-ancestors 'self'" },
{ key: 'X-Frame-Options', value: 'SAMEORIGIN' },
],
},
];
},
};Don't rely on a meta tag
Browsers ignore frame-ancestors when it appears in a meta http-equiv CSP tag. They also ignore X-Frame-Options set via a meta tag. The protection only works as a real HTTP response header.
If your platform only lets you edit HTML, set the header at a CDN or proxy in front of the site, such as Cloudflare.
<!-- This does NOT work for frame-ancestors --> <meta http-equiv="Content-Security-Policy" content="frame-ancestors 'self'">
Purge caches and verify the result
Clear any page cache, plugin cache or CDN cache so the new headers are actually served. Then run curl against the homepage again and confirm at least one passing header appears. Finally, check that your own iframes still work, such as embedded widgets, page-builder previews and partner embeds.
curl -sI https://example.com | grep -iE 'x-frame-options|content-security-policy' # expected: # content-security-policy: frame-ancestors 'self' # x-frame-options: SAMEORIGIN
Platform-specific notes
WordPress
WordPress core sends X-Frame-Options: SAMEORIGIN only on wp-login.php and wp-admin, not on public pages. Add the headers in Nginx or .htaccess, in a security plugin's headers setting, or with a send_headers hook in a small plugin: add_action('send_headers', function () { header("Content-Security-Policy: frame-ancestors 'self'"); header('X-Frame-Options: SAMEORIGIN'); }); Caching plugins that serve static HTML through .htaccess or Nginx skip PHP, so PHP-set headers can disappear on cached hits. Server-level headers avoid this.
Shopify
You cannot edit server headers on Shopify. Storefronts normally already send a frame-ancestors rule and/or X-Frame-Options themselves. If the check fails, test the exact domain with curl. A proxy or CDN in front of the store, or a custom domain pointing elsewhere, may be stripping the headers, and that is where you fix it.
Cloudflare
For hosts that don't allow custom headers, go to Rules > Transform Rules > Modify Response Header > Create rule. Match the hostname example.com, then add two Set static headers: Content-Security-Policy = frame-ancestors 'self' and X-Frame-Options = SAMEORIGIN. If the origin already sends a CSP, a Set operation replaces it, so copy the full existing policy into the new value.
Netlify
Add a _headers file to your publish directory with the line /* followed by indented lines: Content-Security-Policy: frame-ancestors 'self' and X-Frame-Options: SAMEORIGIN. A [[headers]] block in netlify.toml also works. Redeploy for it to take effect.
Wix / Webflow / Squarespace
These hosted builders do not let you set arbitrary response headers on standard plans. First check with curl whether the platform already sends X-Frame-Options or frame-ancestors. If it does not, the only option is a reverse proxy or CDN layer you control, or an enterprise plan with custom header support.
Check that it worked
✅ How to verify
- Run curl -sIL https://example.com | grep -iE 'x-frame-options|content-security-policy' and confirm X-Frame-Options shows DENY/SAMEORIGIN or the CSP includes frame-ancestors.
- In Chrome DevTools, go to Network, reload, select the main document and check Response Headers for the same values.
- Create a test page on a different domain containing <iframe src="https://example.com"></iframe>. The console should report that framing was refused because of frame-ancestors or X-Frame-Options.
- Re-run the audit and confirm the clickjacking protection check passes.
⚠️ Common mistakes
- Setting frame-ancestors in a meta tag or in Content-Security-Policy-Report-Only, both of which leave the site unprotected.
- Using X-Frame-Options: ALLOW-FROM, which modern browsers ignore and which does not pass the check. Use frame-ancestors with a list of origins instead.
- Adding add_header in the Nginx server block when a location block has its own add_header lines, which silently drops the new headers for that location.
- Overwriting an existing CSP at the CDN or .htaccess level and breaking script or style rules, instead of appending frame-ancestors to the current policy.
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 freeFAQ
Should I use X-Frame-Options or CSP frame-ancestors?
Use frame-ancestors as your main control. It is the current standard and supports multiple allowed origins. Add X-Frame-Options: SAMEORIGIN as a fallback for old browsers. When both are present, modern browsers follow frame-ancestors.
Will frame-ancestors break YouTube embeds or other iframes on my site?
No. frame-ancestors controls who can frame your pages, not which iframes your pages can load. Embedding YouTube, maps or forms is governed by frame-src/child-src, which this change does not touch.
What is the difference between frame-ancestors 'self' and 'none'?
'self' allows your own origin to frame the page, which some admin tools, previews and lightboxes need. 'none' blocks every site, including yours. Both pass the check. 'self' is the safer default unless you know nothing on your domain uses iframes of your own pages.
Do I need the header on every page or just the homepage?
The audit tests the homepage, but attackers target login, checkout and account pages. Apply the header site-wide, for example with Nginx server-level add_header, Apache Header always set, or a source of /(.*) in Next.js.
How to Fix a Missing Permissions-Policy Header on Your Site
How to Fix Cookies Missing the SameSite Attribute
How to Fix Vulnerable JavaScript Libraries on Your Site
How to Fix Cookies Missing the HttpOnly Flag on Your Site
How to Fix Server Version Disclosure in HTTP Headers
How to Fix Cookies Missing the Secure Flag on HTTPS