JupyterHub Apache Proxy Reverse not working

Hello everyone,
not sure if this is a JupyterHub or Apache problem, or a mix of both.
I’m currently setting up a JupyterHub for my university, where users will have to authenticate through Shibboleth. The desired result would be that when accessing the Hub via it’s DNS, you get passed on to the Shibboleth-Server, where you will have to enter your credentials and log in, and then you get redirected back to the Hub. I’m trying to achieve this using an Apache Proxy Reverse, and it works up to the point where instead of getting redirected back to the Hub, I’m just getting the Apache Default Page.

I have a bachelor thesis from a different university on this very subject, which I use as a “how-to”-guide, and apparently this is what it has to look like:

  • the jupyterhub_config.py

    import os
    import subprocess
    import pwd

    c.JupyterHub.bind_url = ‘http://:8000/jupyterhub/’
    c.Authenticator.admin_users = {‘dummy’, ‘47b6’}
    c.JupyterHub.authenticator_class = ‘jhub_remote_user_authenticator.remote_user_auth.RemoteUserLocalAuthenticator’
    c.Authenticator.delete_invalid_users = True
    c.Authenticator.allowed_users = ([‘47b6’])
    c.LocalAuthenticator.create_system_users = True
    def create_dir_hook(spawner):
    username = spawner.user.name
    try:
    pwd.getpwnam(username)
    except KeyError:
    subprocess.check_call([‘useradd ‘, ‘-ms’,’/bin/bash’, username])
    c.Spawner.pre_spawn_hook = create_dir_hook
    c.JupyterHub.ssl_cert = ‘/home/dummy/certificate.pem’
    c.JupyterHub.ssl_key = ‘/home/dummy/key.pem’

  • the Apache config in /etc/apache2/sites-available/sp-proxy.conf

    <VirtualHost * :80>
    ServerName jupyterhubtest.oth-aw.de
    Redirect / h ttps://jupyterhubtest.oth-aw.de/ (no typo just to match the criterias for posting)
    < /VirtualHost>
    < IfModule mod_ssl.c>
    <VirtualHost * :443>
    ServerAdmin webmaster@localhost
    # DocumentRoot /var/www/index.html
    ServerName jupyterhubtest.oth-aw.de
    ProxyRequests Off
    RewriteEngine On
    RewriteCond %{HTTP:Connection} Upgrade [NC]
    RewriteCond %{HTTP:Upgrade} websocket [NC]
    RewriteRule /jupyterhub/(.*) ws://jupyterhubtest.oth-aw.de:8000/jupyterhub/$1 [P]
    <Location /jupyterhub/>
    ProxyPreserveHost On
    ProxyPass “h ttp://jupyterhubtest.oth-aw.de:8000/jupyterhub/” (no typo just to match the criterias for posting)
    ProxyPassReverse “h ttp://jupyterhubtest.oth-aw.de:8000/jupyterhub/” (no typo just to match the criterias for posting)
    < /Location>
    SSLEngine on
    SSLCertificateFile /home/dummy/certificate.pem
    SSLCertificateKeyFile /home/dummy/key.pem
    SSLCertificateChainFile /home/dummy/ca-chain.txt
    < /VirtualHost>
    < /IfModule>

The part I think I’m missing is when it comes to defining a “DocumentRoot” in the Apache config file, which is currently commented out. When I create some kind of example index html file, it correctly redirects me to that index page.

But how do I set or find an index page for the Hub? In the bachelor thesis I have it just says “DocumentRoot /var /www /”, and in the JupyterHub Docs that part is just left out completely. Any suggestions?

I’m running the latest Ubuntu-version, all necessary Apache-mods installed and activated, ports open and all… I can’t wrap my head around it…

Have you tried setting c.JupyterHub.base_url?

1 Like

i made it work, for anyone curious here’s the solution:

the hub is bound to jupyterhubtest.oth-aw.de/jupyterhub/, but i just tried to access it via jupyterhubtest.oth-aw.de . Using the full url, it works.

Sometimes it’s the little things… :wink: