LocalProcessSpawner unable to fix 404 redirect errors (original) (raw)

I am running Jupyterhub in Docker in a multi-user environment. This has been plaguing me for sometime, as every permuation I try fails.

Using the SimpleLocalProcessSpawner works under my configuration, but LocalProcessSpawner does not. I want to move away from SimpleLocalProcessSpawner as it is a security risk and because it launches shells under root, not under the user. I’m trying to resolve the seemingly simple issue of fixing the redirect/404 but have exhausted my ability to try anything else.

Any fresh eyeballs would be greatly appreciated. Thanks in advance.

jupyterhub_config.py


#spawner_class = SimpleLocalProcessSpawner                                                                                                                                  
spawner_class = LocalProcessSpawner
c.JupyterHub.spawner_class = spawner_class

# Option A: Use SimpleLocalProcessSpawner                                                                                                                                   
# This works but is insecure and launches shell as root                                                                                                                     
if spawner_class ==  SimpleLocalProcessSpawner:
    c.Spawner.args = ["--allow-root"]
    c.JupyterHub.bind_url = 'http://0.0.0.0:8000/jupyterhub2/'
    # this works                                                                                                                                                            
    # upon successful login we are redirected to:                                                                                                                           
    #https://pdc1rfisgssap02.fnfis.com/jupyterhub2/user/e5577653/lab/workspaces/auto-4                                                                                      

# Option B: Use LocalProcessSpawner                                                                                                                                         
# This our prefered method but I can't get URLs to redirect correctly without 404 errors                                                                                    
elif spawner_class == LocalProcessSpawner:
    c.JupyterHub.bind_url = 'http://0.0.0.0:8000/jupyterhub2/'
    c.Spawner.base_url = '/jupyterhub2'
    c.Spawner.default_url = '/lab'
    c.JupyterHub.cleanup_servers = False

container logs


 JupyterHub is now running at http://0.0.0.0:8000/jupyterhub2/
 200 GET /jupyterhub2/user/e5577653/api (@127.0.0.1) 
 jupyterhub and jupyterhub-singleuser both on version 5.2.1
 Adding user e5577653 to proxy /jupyterhub2/user/e5577653/ => http://127.0.0.1:36109
 201 POST /api/routes/jupyterhub2/user/e5577653 
 302 GET /jupyterhub2/hub/spawn-pending/e5577653 -> /jupyterhub2/user/e5577653/ 
 302 GET /jupyterhub2/user/e5577653/ -> /jupyterhub2/user/e5577653/lab? (@10.218.220.48) 
 404 GET /jupyterhub2/user/e5577653/lab? (@10.218.220.48)

packages

jupyter-events==0.12.0
jupyter-lsp==2.2.5
jupyter-server-mathjax==0.2.6
jupyter_client==7.4.9
jupyter_core==5.7.2
jupyter_server==2.15.0
jupyter_server_proxy==4.4.0
jupyter_server_terminals==0.5.3
jupyterhub==5.2.1
jupyterhub-ldapauthenticator==2.0.2
jupyterlab==4.4.0
jupyterlab-dash==0.1.0a3
jupyterlab_git==0.51.1
jupyterlab_pygments==0.3.0
jupyterlab_retrieve_base_url==0.1.6
jupyterlab_server==2.27.3

manics April 20, 2025, 3:46pm 2

If you want to change the base URL you should do that on JupyterHub, not on Spawner.

minrk April 23, 2025, 8:34am 3

This suggests jupyterlab is not available. This could be a permission or path error. Have you created a virtualenv as root? Is that env fully readable and executable by all users on the system? Can you share the full startup logs of the singleuser server? It should have quite a few messages about loading/enabling jupyter server extensions and versions.