在远程服务器上运行时指定 Jupyter Notebook 的主机名

Dan*_*ats 6 python jupyter-notebook

我正在远程服务器上运行笔记本,我通过浏览器从本地计算机连接到该服务器。我的一个小烦恼是它在开始时打印:

Serving notebooks from local directory: /home/xxxxxxx
0 active kernels
The Jupyter Notebook is running at:
http://(friendly or 127.0.0.1):8888/
Run Code Online (Sandbox Code Playgroud)

friendly主机的友好名称在哪里。主机的 FQDN 实际上是friendly.x.y.z.com. 我希望它打印这个:

The Jupyter Notebook is running at:
http://friendly.x.y.z.com:8888/
Run Code Online (Sandbox Code Playgroud)

这样就可以从控制台直接单击该 URL。我可以在 jupyter 笔记本中传递一个配置选项来明确指定我想要显示的主机名吗?

需要明确的是,http://friendly.x.y.z.com:8888/尽管出现上述消息,浏览器仍能正确解析。

小智 2

您应该首先生成配置文件:

jupyter notebook --generate-config
Run Code Online (Sandbox Code Playgroud)

然后使用配置文件,您可以通过编辑配置文件 ~/.jupyter/jupyter_notebook_config.py 更改以下行来设置自定义 URL:

c.NotebookApp.custom_display_url = 'http://friendly.x.y.z.com:8888'
Run Code Online (Sandbox Code Playgroud)

因此,当您启动服务器时,它将显示此 URL 和令牌。