作者: 文章来源:
本文原地址:https://www.mimiwuqi.com/webqianduan/195802.html
目录文章目录Refused to display '嵌套的网址' in a frame because it set 'X-Frame-Options' to 'sameorigin'.
关于 X-Frame-Options:
X-Frame-Options 是一个 HTTP 响应头部,用于防止网站被嵌入到其他网站的 iframe 中。该协议定义了一些选项,使网站可以控制在哪些网站中可以嵌入自己的内容,从而防止网站被点击劫持攻击。
X-Frame-Options 协议有三种选项:
如果网站设置了 X-Frame-Options 响应头部,浏览器会根据该选项来决定是否允许在 iframe 中显示该网站的内容。这有助于防止网站遭受点击劫持等攻击,并提高网站的安全性。
Refused to frame '嵌套的网址' because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self'
CSP 是一种安全功能,通过指定允许哪些域将网站内容嵌入框架或 iframe 来帮助防止跨站点脚本 (XSS) 攻击。
白话:把你的地址给第三方,让第三方信任你的网址才能嵌套
这两个方式都能使用nginx代码解决。
location / {
proxy_hide_header X-Frame-Options;
proxy_pass [你代理的网址];
}
proxy_hide_header指令用于从代理服务器接收的响应中删除“X-Frame-Options”标头。
location / {
proxy_hide_header Content-Security-Policy;
proxy_hide_header X-Frame-Options;
proxy_pass https://www.mybj123.com;
}
并隐藏来自该网站的两个响应头:“Content-Security-Policy” 和 “X-Frame-Options”。
更多 建站教程 请访问 https://www.mimiwuqi.com/webqianduan/