Skip to content

Kompile Learn

Stop clickjacking (X-Frame-Options and frame-ancestors)

Prevent other sites from loading your pages inside an invisible frame and tricking visitors into clicking.

What it is

Clickjacking puts your page in a hidden frame on a hostile site, so a visitor thinks they are clicking one thing but click a button on your page instead.

Why it matters

It can make logged-in users change settings, make purchases, or grant permissions without realising it.

How to fix it

nginx

add_header X-Frame-Options "DENY" always;

Apache

Header always set X-Frame-Options "DENY"

Modern alternative (CSP)

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

Use SAMEORIGIN instead of DENY (or frame-ancestors 'self') if your own site frames its pages.

Does your site have this problem?

Kompile Scan checks for this and the other problems in these guides in under a minute. Free for one site.

Check my site