无法将在Jupyterhub上运行的Jupyterlab嵌入到iframe中

阿舒托什·斯里瓦斯塔瓦(Ashutosh srivastava)

我正在尝试将与jupyterhub一起运行的jupyterlab集成到iframe中。我在配置文件中进行了所有必需的更改。在jupyter_notebook_config.py中,我进行了以下更改。

c.NotebookApp.tornado_settings = {'headers': {
    'Access-Control-Allow-Origin': '*',
    'Content-Security-Policy': 'frame-ancestors http://localhost:9005'
  }}

而在jupyterhub_config.py中,我添加了以下内容

c.JupyterHub.tornado_settings = {'headers': {
    'Access-Control-Allow-Origin': '*',
    'Content-Security-Policy': 'frame-ancestors http://localhost:9005'
  }}

但是,当我尝试在iframe中打开http:// localhost:8002 / user / admin / lab URL时,出现以下错误

Refused to display 'http://localhost:8002/user/admin/lab' in a frame because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self'".

有人可以让我知道我是否缺少某些东西或我的配置有问题吗?

阿玛尔(Amal Vijayan)

这是一个解决方法,

  • 对于所有登录Jupyterhub的用户,都有一个通用的笔记本配置文件。
  • 将配置文件作为spawner args传递。

请按照以下步骤操作:

  1. 在特定位置(例如/ home / shared_config /)创建一个名为jupyter_notebook_config.py的文件。

您可以使用文本编辑器(如vim)手动创建文件,也可以使用以下命令使用jupyter notebook生成默认的coinfig文件

jupyter notebook --generate-config

请注意,以上命令要求安装jupyter笔记本(pip3 install jupyterhub笔记本)

安装后,如果在加载tljh-config时遇到与ruamel.yaml版本相关的错误,请执行以下命令:pip3 install ruamel.yaml == 0.15。*

  1. 打开上面创建的jupyter_notebook_config.py文件,并添加以下代码:

    c.NotebookApp.tornado_settings = {'headers':{'Content-Security-Policy':“ frame-ancestors *'self'”}}

使用以下代码更改文件的权限:

chmod -R 755 /home/shared_config/jupyter_notebook_config.py
  1. 打开您的jupyterhub配置文件(默认情况下位于/opt/tljh/config/jupyterhub_config.d/jupyterhub_config.py中)并添加以下代码:

注意:您可以使用以下命令生成jupyterhub配置文件:jupyterhub --generate-config

c.Spawner.args = [ '--config=/home/shared_config/jupyter_notebook_config.py']
  1. 使用以下命令重新加载tljf-config:

    sudo tljf-config重新加载

快乐编码!

这是我的配置

-/opt/tljh/config/jupyterhub_config.d/jupyterhub_config.py

c.JupyterHub.tornado_settings = {'headers': {'Content-Security-Policy': "frame-ancestors * 'self' "}}
c.Spawner.args = [ '--config=/home/ubuntu/jupyter_notebook_config.py']

-/home/shared_config/jupyter_notebook_config.py

c.NotebookApp.tornado_settings={'headers': {'Content-Security-Policy': "frame-ancestors * 'self' "}}

一些有用的参考和相关问题:

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在Jupyterhub中升级JupyterLab

无法在 Joomla 中嵌入 iframe

如何将Facebook组(非常规页面)嵌入到Wordpress上的iframe中?

YouTube嵌入无法在Node + React上运行

将Firebase社交登录嵌入到iframe中

将Google Apps脚本嵌入到iFrame中

检查网站是否可以通过HTTP嵌入到iframe中

你如何将 iframe 嵌入到 Markdown 中

如何在 jupyterlab 或 notebook 中嵌入 vega?

在jupyterlab中运行highcharter / jupyternotebooks

嵌入的PDF无法在使用当前代码的IE上运行

YouTube嵌入的实时聊天无法在移动设备上运行(最近)

无法在wkwebview中运行html中嵌入的javascript

在 Linux 机器上的 minikube 中安装 jupyterhub

使用GPU在Tensorflow教程中无法运行单词嵌入示例

mysql:无法将select嵌入到select中

如何将 GeoJSON 嵌入到 GitHub 上的 markdown 中?

将在docker上运行的应用程序生成的文件保存到主机中的给定路径

检测Java中嵌入的iFrame

将iframe嵌入图像中

无法使用jupyterhub运行ipython-notebook 2.7

如何在Ubuntu服务器(AWS)上运行jupyterhub

Docker 入口点未在 jupyterhub 上以 root 身份运行

阻止在chrome上嵌入的youtube iframe上捕获iframe滚动

如何将按键事件发送/调度到 React 中的嵌入式 iframe?

有没有办法将github代码嵌入到iframe中?

(如何)可以将带有iframe代码的内容嵌入到powerpoint 2010中?

将视频播放器html5 iframe嵌入到YouTube之类的Facebook共享中

将SSRS 2016报告嵌入到没有iFrame的另一个网页中?