Trouble reverse proxying to JupyterHub on a subpath

I fixed the static content issue. I had to remove a trailing slash from the nginx proxy_pass directive. Everything is now working correctly.

Final Summary

  1. Had to force the JupyterHub configuration file to be sourced on container startup by adding the line to the end of the Dockerfile:
CMD ["jupyterhub", "-f", "/etc/jupyterhub/jupyterhub_config.py"]
  1. Since I am serving JupyterHub through a reverse proxy on the subpath twopyter, I had to set the c.JupyterHub.bind_url configuration variable with:
c.JupyterHub.bind_url = 'http://:8000/twopyter/'
  1. In the reverse proxy Nginx configuration, you cannot have a trailing slash after your proxy_pass directive. If you do, the static page content will be unable to load. Once I fixed this, it solved the last remaining problem. I do not understand why it breaks things, but that’s the way it is. So for us it looks like this:
    location /twopyter/ {
        proxy_pass              http://host.docker.internal:15080;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

        # websocket headers
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }
}

Thank you @manics for all your help.

1 Like