JupyterHub and another web application behind Nginx


I have installed TLJH on a server, along with a web application (Django). I am now trying to run both TLJH and the web application behind a Nginx reverse proxy on the same domain name. TLJH will be accessible with a different location (e.g. my-domain/jupyter).

Currently, only the web application is accessible and I would really appreciate some help.

I have followed both Nginx - HTTPS configuration and JupyterHub - Using a reverse proxy.

Here is my Nginx configuration:

ssl_certificate ...
ssl_certificate_key ...

map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;

# Django my-website
server {
        listen 80;
        listen 443 ssl;
        server_name my-domain;

        location /static/ {
                root /var/www/my-website;

        location / {
                proxy_set_header Host $http_host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarder-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_pass http://unix:/run/my-website.sock;

        # Managing literal requests to the JupyterHub frontend
        location /jupyter/ {
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header Host $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;

And here is my TLJH configuration:

  port: 8000

If you want Jupyterhub to run from a URL that isn’t the server root, you need to configure base_url to tell it about the prefix. See the “Base URL” section of the TLJH config doc.

I can’t believe that was all that was missing.

Thank you for your help!