nginx X-Frame-Options still with the same value

nginx X-Frame-Options still with the same value

October 19, 2026 · Illustrated author avatarBy Stefan Bogdanescu
nginx X-Frame-Options still with the same value

Understanding X-Frame-Options: Debugging and Resolving Frameset Issues

X-Frame-Options is an HTTP response header that defines whether a web page can be framed or not within another document. It’s a crucial security feature for preventing your website from being embedded in malicious framesets, which could lead to clickjacking attacks or data theft.

You’re currently experiencing an issue where the X-Frame-Options value remains as ‘SAMEORIGIN’ even after removing it from your Nginx configuration, causing iFrames on your website to be blocked. Let’s dive into the reasons behind this behavior and provide a step-by-step solution.

Why X-Frame-Options Persists

The persistence of the X-Frame-Options header can occur due to several reasons:

  1. Caching: Browsers cache HTTP headers for performance optimization. Even after you’ve changed your Nginx configuration, the cached version of the header might still be in use.

  2. Shared Hosting or Multi-Site Configuration: If you’re on a shared hosting server or running multiple sites from the same domain (like www.example.com and example.com), other sites on the same server could be setting this header value.

  3. Frame Options Set by Other Libraries or Plugins: Some JavaScript libraries, content delivery networks (CDNs), or plugins might also set their own X-Frame-Options headers.

Debugging and Resolving the Issue

Step 1: Check Your Entire Nginx Configuration

Ensure that you’ve removed all instances of add_header X-Frame-Options SAMEORIGIN; from your entire Nginx configuration file. This includes server blocks, location blocks, and any custom modules or plugins.

Step 2: Purge Browser Cache and Restart Server

Even after changing the configuration, you’ll need to purge the browser cache and restart both your webserver (Nginx) and PHP-FPM:

# Purge browser cache for Chrome/Firefox
chrome --purge-memory-cache
firefox -P default -no-remote -purgecaches

# Restart Nginx and PHP-FPM
sudo systemctl restart nginx php-fpm

Step 3: Use a Different Header Value Temporarily

As a diagnostic step, try setting the header to an invalid value or a different valid one:

add_header X-Frame-Options "NOFRAMES";

or

add_header X-Frame-Options "ALLOWALL";

If this changes the behavior and allows iFrames, it confirms that your Nginx configuration is being applied correctly.

Step 4: Check Other Headers and Embedded Resources

Use browser developer tools to inspect the headers of all embedded resources (CSS, JavaScript, images) on your page. It’s possible that one of these resources might be setting a conflicting X-Frame-Options header.

If you find any conflicts, you’ll need to address them by:

  1. Removing or updating the external resource.
  2. Using a Content Security Policy (CSP) to control which domains can embed your content.

Conclusion

Debugging X-Frame-Options issues requires a systematic approach that combines understanding of HTTP caching, server configurations, and potential conflicts from embedded resources.

Remember that security headers like X-Frame-Options are designed for protection. It’s essential to have them in place even if it means blocking some legitimate uses of iFrames temporarily during development or testing phases.

For more detailed guides on Nginx configuration best practices, check out our comprehensive guide at Laravel Company.

Cache Performance Security Extensions

Our network