Jupyter远程访问

当我使用 深度学习环境 时,由于是在 FreeBSD Linux Jail 结合 FreeBSD VNET Jail ,所以在我的 MacBook Pro 15" Late 2013 中需要远程访问 Jupyter

由于 Jupyter Notbook服务器默认只监听回环地址,所以需要修订启动配置:

  • 先生成 Jupyter 配置文件:

生成 Jupyter 配置文件
jupyter notebook --generate-config

此时提示可以看到输出了一个默认启动配置:

生成 Jupyter 默认配置文件
Writing default config to: /home/admin/.jupyter/jupyter_notebook_config.py
  • 修订 ~/.jupyter/jupyter_notebook_config.py :

修订 ~/.jupyter/jupyter_notebook_config.py
## Set the Access-Control-Allow-Origin header
#  
#          Use '*' to allow any origin to access your server.
#
#          Takes precedence over allow_origin_pat.
#  Default: ''
# c.ServerApp.allow_origin = ''
c.ServerApp.allow_origin = '*'

## The IP address the Jupyter server will listen on.
#  Default: 'localhost'
# c.ServerApp.ip = 'localhost'
c.ServerApp.ip = '0.0.0.0'
  • 然后再次启动 jupyter notebook 就会监听所有网卡接口,就能够从远程访问Notebook

参考