简体   繁体   English

IE 和 Chrome 的 Apache X-Frame-Options 冲突(只有一个有效!)

[英]Apache X-Frame-Options conflict for IE and Chrome (only either one worked!)

I have a site that I need to load resources from itself as well as from another URL.我有一个网站,我需要从它自己以及另一个 URL 加载资源。

Therefore, in Apache, I added both the SAMEORIGIN and the ALLOW-FROM.因此,在 Apache 中,我添加了 SAMEORIGIN 和 ALLOW-FROM。

Interestingly, Chrome refused to show the page, stating that there is multiple X-Frame-Options headers with conflicting values, and falling back to 'deny'.有趣的是,Chrome 拒绝显示该页面,指出有多个 X-Frame-Options 标头具有冲突的值,并退回到“拒绝”。 On the other hand, IE works fine!另一方面,IE 工作正常!

I modified it by removing the SAMEORIGIN and added my the originating site URL into the ALLOW-FROM.我通过删除 SAMEORIGIN 对其进行了修改,并将我的原始站点 URL 添加到 ALLOW-FROM 中。 This time, Chrome works, but IE does not!这一次,Chrome 可以工作,但 IE 不行!

In case you wanted to try, these are the settings that I used that experience the issue:如果您想尝试,这些是我使用的遇到问题的设置:

# Test 1: Use these 2 lines will make IE work, but not Chrome
Header always append X-Frame-Options "SAMEORIGIN"
Header always append X-Frame-Options "ALLOW-FROM https://www.google.com"

# Test 2: Use these 2 lines will make Chrome work, but not IE 
# (<MyBaseServerURL> represents the location as indicated by the "SAMEORIGIN")
Header always append X-Frame-Options "ALLOW-FROM https://www.google.com"
Header always append X-Frame-Options "ALLOW-FROM https://<MyBaseServerURL>"

Could someone advise how I could resolve this?有人可以建议我如何解决这个问题吗?

Thanks and regards, Jacky谢谢和问候, 杰基

This is because ALLOW-FROM is only supported in FireFox.这是因为 ALLOW-FROM 仅在 FireFox 中受支持。

Use a Content Security Policy instead.改用内容安全策略。

Nginx: nginx:

add_header Content-Security-Policy "frame-src self *.mydomain.example";

The X-Frame-Options HTTP response header can be used to indicate whether or not a browser should be allowed to render a page in a , , or . X-Frame-Options HTTP 响应标头可用于指示是否应允许浏览器以 、 或 呈现页面。 Sites can use this to avoid click-jacking attacks, by ensuring that their content is not embedded into other sites.网站可以使用它来避免点击劫持攻击,确保他们的内容没有嵌入到其他网站中。

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM