因为最近项目需要开启iframe形式来加载页面,
遇到浏览器 报错 Load denied by X-Frame-Options: ************* does not permit cross
X-Frame-Options
HTTP
响应头是用来给浏览器指示允许一个页面可否在
<frame>
, <iframe>
或者 <object>
中展现的标记。网站可以使用此功能,来确保自己网站的内容没有被嵌到别人的网站中去,也从而避免了点击劫持 (clickjacking) 的攻击。
他的值:
(1)DENY --- 表示该页面不允许在 frame 中展示,即便是在相同域名的页面中嵌套也不允许。
(2)SAMEORIGIN --- 表示该页面可以在相同域名页面的 frame 中展示。
(3)ALLOW-FROM https://example.com/ --- 表示该页面可以在指定来源的 frame 中展示。
如果是不限制 则配置 ALLOWALL ,但是就不安全了
配置 Apache
配置 Apache 在所有页面上发送 X-Frame-Options 响应头,需要把下面这行添加到 'site' 的配置中:
Header always append X-Frame-Options
ALLOWALL
配置 nginx
配置 nginx 发送 X-Frame-Options 响应头,把下面这行添加到 'http', 'server' 或者 'location' 的配置中:
add_header X-Frame-Options ALLOWALL