从另一个域运行iframe中的IPython Notebook

rob*_*bor 5 iframe ipython ipython-notebook

我想在另一台服务器上的iframe内部运行我的服务器上的IPython笔记本.我收到此错误:

Refused to display 'my_url/Test.ipynb' in a frame because 
it set 'X-Frame-Options' to 'SAMEORIGIN'
Run Code Online (Sandbox Code Playgroud)

这里它说我应该为此设置一些x-frame-header选项:http: //ipython.org/ipython-doc/dev/whatsnew/development.html#iframe-embedding

我在哪里可以设置这个?如何更改此X-Frame-Option以便可以从其他站点嵌入?:)

rob*_*bor 3

更新

根据@simon的回答(/sf/answers/5275075571/),您现在应该将以下内容添加到 ipython_notebook_config.py

c.NotebookApp.tornado_settings = {
    'headers': {
        'Content-Security-Policy': "frame-ancestors https://mywebsite.example.com 'self' "
    }
}
Run Code Online (Sandbox Code Playgroud)

(参见 https://jupyter-notebook.readthedocs.io/en/stable/public_server.html#embedding-the-notebook-in-another-website

先前更新

根据哈里森的评论,应该是

c.NotebookApp.tornado_settings = {'headers': {'X-Frame-Options': 'ALLOW-FROM https://example.com/'}}
Run Code Online (Sandbox Code Playgroud)

现在,另请参阅http://jupyter-notebook.readthedocs.io/en/stable/config.html

原帖

好的,我找到了一个有效的解决方案,但我不确定这是否是正确的方法:在.ipython/your_profile/ipython_notebook_config.py添加

c.NotebookApp.webapp_settings = {'headers': {'X-Frame-Options': 'ALLOW-FROM https://example.com/'}}
Run Code Online (Sandbox Code Playgroud)

对我有用,但不确定这是否会覆盖龙卷风或其他任何东西的更多设置:)

  • `webapp_settings` 现已弃用。而是使用“tornado_settings”。 (2认同)