Rob's web

X-Frame-Options

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

Warning: Instead of this header, use the frame-ancestors directive in a Content-Security-Policy header.

The X-Frame-Options HTTP response header can be used to indicate whether a browser should be allowed to render a page in a <frame>, <iframe>, <embed> or <object>. Sites can use this to avoid click-jacking attacks, by ensuring that their content is not embedded into other sites.

The added security is provided only if the user accessing the document is using a browser that supports X-Frame-Options.

Directives

If you specify DENY, not only will the browser attempt to load the page in a frame fail when loaded from other sites, attempts to do so will fail when loaded from the same site. On the other hand, if you specify SAMEORIGIN, you can still use the page in a frame as long as the site including it in a frame is the same as the one serving the page.

DENY The page cannot be displayed in a frame, regardless of the site attempting to do so.
SAMEORIGINDeprecatedThe page can only be displayed if all ancestor frames are same origin to the page itself.
ALLOW-FROM originDeprecatedThis is an obsolete directive. Modern browsers that encounter response headers with this directive will ignore the header completely. The Content-Security-Policy HTTP header has a frame-ancestors directive which you should use instead.

Setting a policy

As an example we will use SAMEORIGIN.

This policy can only be set in the header. The <meta> will not work.

Global

This is the preferred option.

# cd /etc/httpd/conf/
# vi httpd.conf
Header always set Referrer-Policy "SAMEORIGIN"
# httpd -t
# systemctl restart httpd

Virtualhost

This option should only be used if you need a different policy for this site.

This must be set in the virtual host *:443 section.

# cd /etc/httpd/conf/vhosts/
# vi <URL>.conf
Header always set Referrer-Policy "SAMEORIGIN"
# httpd -t
# systemctl restart httpd

Links