首页 > 解决方案 > 在远程服务器上运行时为 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/

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

The Jupyter Notebook is running at:
http://friendly.x.y.z.com:8888/

以便可以从控制台直接单击 URL。是否有一个配置选项我可以在 jupyter notebook 中传递某个地方来明确指定我想要显示的主机名?

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

标签: pythonjupyter-notebook

解决方案


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

jupyter notebook --generate-config

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

c.NotebookApp.custom_display_url = 'http://friendly.x.y.z.com:8888'

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


推荐阅读