Jupyter-hub

Author: Martin Horvat, Luciano Rivetti, Andrej Studen, October 2023

Install

apt-get install nodejs npm
python3 -m pip install jupyterhub
npm install -g configurable-http-proxy
python3 -m pip install jupyterlab notebook

Config

A. Generating configuration:

mkdir -p /etc/jupyterhub/systemd
cd /etc/jupyterhub
jupyterhub --generate-config

B. Generating systems service:

Edit /etc/jupyterhub/systemd/jupyterhub.service to read

----
[Unit]
Description=JupyterHub
After=syslog.target network.target

[Service]
User=root
WorkingDirectory=/etc/jupyterhub
ExecStart=jupyterhub -f /etc/jupyterhub/jupyterhub_config.py

[Install]
WantedBy=multi-user.target

Perform:

ln -s /etc/jupyterhub/systemd/jupyterhub.service /etc/systemd/system/jupyterhub.service
systemctl enable jupyterhub.service
systemctl start jupyterhub.service

Reverse-proxy

Standard setup, including certbot to generate certificate. Add instructions from documentation, the only
apache module missing was the proxy_wstunnel.

a2enmod ssl rewrite proxy headers proxy_http proxy_wstunnel

Also, add

 RewriteEngine On
  RewriteCond %{HTTP:Connection} Upgrade [NC]
  RewriteCond %{HTTP:Upgrade} websocket [NC]
  RewriteRule /(.*) ws://vangogh.fmf.uni-lj.si:8000/$1 [P,L]

to apache site configuration file under <VirtualHost>, and under <Location>

RequestHeader     set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}

Test

http://jupyter-vangogh.fmf.uni-lj.si

Discussion