Jupyter Notebook

Running a public Jupyter Notebook server

Running a Public Jupyter Notebook Server

Configure Jupyter Notebook

Create the configuration file

Check if /home/USERNAME/.jupyter/jupyter_notebook_config.py exists, if not, run:

jupyter notebook --generate-config

Edit the configuration file

Edit /home/USERNAME/.jupyter/jupyter_notebook_config.py for the following:

Prevent the browser from opening after launching

c.ServerApp.open_browser = False

Listen IP

c.ServerApp.ip = '*'

Specify port, remember to edit the firewall accordingly

c.ServerApp.port = 8888

SSL/TLS

c.ServerApp.certfile = u'/absolute/path/to/your/certificate/fullchain.pem'
c.ServerApp.keyfile = u'/absolute/path/to/your/certificate/privkey.pem'

Save and exit.

Set a password

jupyter notebook password

Wrap into a systemd service

Check the location of the jupyter binary

which jupyter

As root, save the following as jupyter.service under /etc/systemd/system. Substitute the values of User, Group, WorkingDirectory, and ExecStart to the actual values:

[Unit]
Description=Jupyter Notebook
After=network.target

[Service]
Type=simple
User=bob
Group=bob
WorkingDirectory=/home/bob/Notebooks
ExecStart=/home/bob/miniconda3/envs/foo/bin/jupyter notebook
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

Save and exit, then run:

sudo systemctl enable jupyter.service
sudo systemctl start jupyter.service

References

https://jupyter-server.readthedocs.io/en/latest/operators/public-server.html

ChatGPT

Content Licensed under CC BY-SA 4.0. Code licensed under the MIT License.