I'm using nginx
as a reverse proxy for my website.
I want to be able to open my website in an iFrame
from a chrome extension new tab html file.
For this, I need my nginx
to set X-Frame-Options
to allow all domains.
According to this answer, all domains is the default state if you don't set X-Frame-Options.
My /etc/nginx/nginx.conf
doesn't have the X-Frame-Options set anywhere.
Yet when I check my website response header using Postman, it shows me X-Frame-Options = SAMEORIGIN
.
How can I remove this setting and load my website in an iFrame in the chrome new-tab .html file?
To enable the X-Frame-Options header in Nginx, add the following line in your Nginx web server default configuration file /etc/nginx/sites-enabled/example. conf: add_header X-Frame-Options "SAMEORIGIN"; Next, restart the Nginx service to apply the changes.
Double-click the HTTP Response Headers icon in the feature list in the middle. In the Actions pane on the right side, click Add. In the dialog box that appears, type X-Frame-Options in the Name field and type SAMEORIGIN in the Value field. Click OK to save your changes.
X-Frame-Options:DENY is a header that forbids a page from being displayed in a frame. If your server is configured to send this heading, your sign-on screen will not be allowed to load within the embed codes provided by Credo, which use the iframe HTML element.
You can remove the HTTP header X-Frame-Options: SAMEORIGIN from WordPress by removing the send_frame_options_header function from the admin_init and login_init hooks. For example, you can add the following to your theme's functions.
Solved it by changing proxy_hide_header values in /etc/nginx/sites-available/default
file like so:
proxy_hide_header X-Frame-Options;
Needed to restart nginx
as well as use pm2
to restart my nodejs
server (for some reason, it didn't work till I made a small change to my server and restarted it).
add_header X-Frame-Options "";
did the trick for me in nginx 1.12.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With