設置 https://developer.mozilla.org/zh-CN/docs/Web/HTTP/X-Frame-Options
可以正常使用
add_header X-Frame-Options ALLOWALL;
語法
X-Frame-Options
有三個可能的值:
X-Frame-Options: deny X-Frame-Options: sameorigin X-Frame-Options: allow-from https://example.com/
指南
換一句話說,如果設置為 deny
,不光在別人的網站 frame 嵌入時會無法加載,在同域名頁面中同樣會無法加載。另一方面,如果設置為sameorigin
,那么頁面就可以在同域名頁面的 frame 中嵌套。
-
deny
- 表示該頁面不允許在 frame 中展示,即便是在相同域名的頁面中嵌套也不允許。
-
sameorigin
- 表示該頁面可以在相同域名頁面的 frame 中展示。
-
allow-from uri
- 表示該頁面可以在指定來源的 frame 中展示。
-
Content-Security-Policy:default-src *; frame-src 'self' wvjbscheme://* https://gjfs.linkfinance.cn http://gjfs-v4.dev.linkfin.caih.local/web/user/login/ http://220.****6:8877/ http://1****.84/ http://2****81/ https://zg******.com/ http://zg****d.com/ http://******/ http://tes******oud.com/ http://xm*****n.com/ https://xm*****n.com/; style-src 'self' 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'; img-src * data: blob:
- 設置完即可使用
-
找到了新的優先級更高的配置
https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors
Content-Security-Policy: frame-ancestors <source>;的優先級 高於X-Frame-Options
add_header Content-Security-Policy "frame-ancestors *"; 所有網頁都可以進行嵌入 - IIS處理辦法,在web.config文件中添加修改如下內容
-
<httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="*" /> <add name="X-Frame-Options" value="ALLOWALL" /> <add name="Content-Security-Policy" value="frame-ancestors *" /> </customHeaders> </httpProtocol>