Jupyter notebook 无法将在Jupyterhub上运行的Jupyterlab嵌入到iframe中
我正在尝试将运行jupyterhub的jupyterlab集成到iframe中。 我在配置文件中做了所有必要的更改。 在jupyter_notebook_config.py中,我做了以下更改Jupyter notebook 无法将在Jupyterhub上运行的Jupyterlab嵌入到iframe中,jupyter-notebook,jupyter,jupyter-lab,jupyterhub,Jupyter Notebook,Jupyter,Jupyter Lab,Jupyterhub,我正在尝试将运行jupyterhub的jupyterlab集成到iframe中。 我在配置文件中做了所有必要的更改。 在jupyter_notebook_config.py中,我做了以下更改 c.NotebookApp.tornado_settings = {'headers': { 'Access-Control-Allow-Origin': '*', 'Content-Security-Policy': 'frame-ancestors http://localhost:90
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中打开URL时,仍然会出现以下错误
拒绝展示http://localhost:8002/user/admin/lab'在帧中,因为祖先违反以下内容安全策略指令:帧祖先'self'
如果我遗漏了什么或配置有问题,有人能告诉我吗?这里有一个解决方法
为所有用户提供一个通用的笔记本配置文件
登录Jupyterhub。
将配置文件作为生成程序参数传递。
按照以下程序操作:
在特定位置创建一个名为jupyter_notebook_config.py的文件,例如/home/shared_config/
您可以使用vim之类的文本编辑器手动创建文件
或者使用jupyter notebook和
跟随命令
请注意,上述命令要求安装jupyter笔记本
pip3安装jupyterhub笔记本电脑
安装后,如果遇到与ruamel.yaml相关的错误
版本加载tljh配置时,执行以下命令:
pip3安装ruamel.yaml==0.15*
打开上面创建的jupyter_notebook_config.py文件,并添加以下代码:
c、 NotebookApp.tornado_设置={'headers':{'Content-Security-Policy':框架祖先*'self'}
使用以下代码更改文件的权限:
默认情况下,打开位于/opt/tljh/config/jupyterhub_config.d/jupyterhub_config.py中的jupyterhub配置文件,并添加以下代码:
注意:您可以使用
以下命令:jupyterhub-generate-config
使用以下命令重新加载tljf配置:
sudo tljf配置重新加载
快乐编码
下面是我的配置的样子
-/opt/tljh/config/jupyterhub_config.d/jupyterhub_config.py
-/home/shared\u config/jupyter\u notebook\u config.py
一些有用的参考资料和相关问题:
我尝试了上述方法,但仍然面临同样的错误。我正在为iframe使用一个简单的HTML文件。帧祖先值应该是多少?试试这个:我在一台单独的机器上运行jupyterhub。我试过了。但我仍然面临同样的问题。拒绝在框架中显示,因为某个祖先违反了以下内容安全策略指令:框架祖先*“self”。我已使iframe正常工作,现在正在获取登录页面。但是,当我尝试登录时,我得到了以下错误:-在跨原点子帧中阻止了对表单控件的自动聚焦。这就是我如何实现iframe嵌入的方法。我遵循了这里的安装教程:tljh.jupyter.org/en/latest,然后完成了上述工作。确保添加一个letsencrypt免费ssl证书-tljh.jupyter.org/en/latest/howto/admin/https.html–Amal Vijayan
jupyter notebook --generate-config
chmod -R 755 /home/shared_config/jupyter_notebook_config.py
c.Spawner.args = [ '--config=/home/shared_config/jupyter_notebook_config.py']
c.JupyterHub.tornado_settings = {'headers': {'Content-Security-Policy': "frame-ancestors * 'self' "}}
c.Spawner.args = [ '--config=/home/ubuntu/jupyter_notebook_config.py']
c.NotebookApp.tornado_settings={'headers': {'Content-Security-Policy': "frame-ancestors * 'self' "}}