What am I doing wrong? - Nginx gives “502 bad gateway”, journalctl
gives no error but also no requests arrive to it:
Jan 30 00:06:44 beefy0 jupyterhub[226528]: [I 2025-01-30 00:06:44.095 JupyterHub app:3770] JupyterHub is now running at http://127.0.0.1:8095/
Python virtualenv
$ uv venv --python '3.10' -- /opt/venvs/jupytervenv-3-10
$ . /opt/venvs/jupytervenv-3-10/bin/activate
$ python -m ensurepip
$ python -m pip install -U pip
$ python -m pip install -U setuptools wheel
$ python -m pip install -U "jupyverse[auth,jupyterlab]" fps-jupyterlab fps-auth jupyter-collaboration oauthenticator jupyterhub-nativeauthenticator
systemd
[Unit]
Description=Job that runs the Jupyter Hub daemon
[Service]
#User=jupyter
#Group=jupyter
User=root
Group=root
Environment="VIRTUAL_ENV=/opt/venvs/jupytervenv-3-10"
Environment="PYTHONPATH=/opt/venvs/jupytervenv-3-10:/opt/venvs/jupytervenv-3-10/bin"
Environment="PATH=/opt/venvs/jupytervenv-3-10/bin:/home/name0/.local/bin:/home/name0/.cargo/bin:/home/name0/.local/share/fnm/aliases/default/bin:/tmp/libscript_data/bin:/usr/local/bin:/usr/bin:/bin:/usr/games"
Environment="JUPYTERHUB_ADMIN_USER=name0"
Environment="JUPYTERHUB_ALLOWED_USERS=name0,name1"
Environment="JUPYTERHUB_PUBLIC_HUB_URL=https://notebook.example.com/"
Environment="__JUPYTERHUB_SERVICE_URL=https://notebook.example.com/hub/api"
Environment="__JUPYTERHUB_API_URL=https://notebook.example.com/hub/api"
Environment="__JUPYTERHUB_BASE_URL=https://notebook.example.com/"
WorkingDirectory=/opt/venvs/jupytervenv-3-10
# --set frontend.collaborative=true \
# --set auth.mode=user \
ExecStart=/opt/venvs/jupytervenv-3-10/bin/jupyterhub \
--Spawner.notebook_dir='/opt/notebooks' \
--LocalProcessSpawner.notebook_dir='/opt/notebooks' \
--SimpleLocalProcessSpawner.notebook_dir='/opt/notebooks' \
--FileContentsManager.preferred_dir='/opt/notebooks' \
--ip='127.0.0.1' \
--port='8095' \
--Authenticator.allowed_users='${JUPYTERHUB_ALLOWED_USERS}' \
--Authenticator.whitelist='${JUPYTERHUB_ALLOWED_USERS}' \
--Authenticator.admin_users='${JUPYTERHUB_ADMIN_USER}' \
--LocalAuthenticator.create_system_users=True \
--JupyterHub.authenticator_class='jupyterhub.auth.DummyAuthenticator' \
--DummyAuthenticator.password='PasswordHere' \
--DummyAuthenticator.allow_all=True \
--allow_existing_users=True \
--DummyAuthenticator.allowed_users='${JUPYTERHUB_ALLOWED_USERS}'
[Install]
WantedBy=multi-user.target
nginx
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
if ($host = notebook.example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name notebook.example.com;
listen 80;
return 404; # managed by Certbot
}
server {
server_name notebook.example.com;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/notebook.example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/notebook.example.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
location / {
proxy_pass http://127.0.0.1:8095;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# websocket headers
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Scheme $scheme;
proxy_buffering off;
}
location ~ /api/kernels/ {
proxy_pass http://127.0.0.1:8095;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# websocket headers
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Scheme $scheme;
proxy_buffering off;
}
location ~ /api/terminals/ {
proxy_pass http://127.0.0.1:8095;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# websocket headers
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Scheme $scheme;
proxy_buffering off;
}
}