Can't login to my server jupyterhub via http

Hello,
I’m trying to set up a jupyterhub on my server and access it via an external network. I’m new on it so I’m using this repo as a starting point. I changed jupyterhub_config.py to use a Dummy authenticator.

The complete file looks like this:

import os

c = get_config()  # noqa: F821

c.JupyterHub.spawner_class = "dockerspawner.DockerSpawner"

c.DockerSpawner.image = os.environ["DOCKER_NOTEBOOK_IMAGE"]

spawn_cmd = os.environ.get("DOCKER_SPAWN_CMD", "start-singleuser.sh")
c.DockerSpawner.cmd = spawn_cmd

network_name = os.environ["DOCKER_NETWORK_NAME"]
c.DockerSpawner.use_internal_ip = True
c.DockerSpawner.network_name = network_name

notebook_dir = os.environ.get("DOCKER_NOTEBOOK_DIR", "/home/jovyan/work")
c.DockerSpawner.notebook_dir = notebook_dir

c.DockerSpawner.volumes = {"jupyterhub-user-{username}": notebook_dir}

c.DockerSpawner.remove = True

c.DockerSpawner.debug = True

c.JupyterHub.hub_ip = "jupyterhub"
c.JupyterHub.hub_port = 8080

c.JupyterHub.cookie_secret_file = "/data/jupyterhub_cookie_secret"
c.JupyterHub.db_url = "sqlite:////data/jupyterhub.sqlite"

c.JupyterHub.authenticator_class = "dummy"

And I also changed the docker-compose.yml file to match the port I want to use for access. It looks like this:

    ...
    volumes:
      ...
    ports:
      - "8787:8000"
    environment:
      ...
...

Running the Docker container I can access the jupyterhub within my localhost and everything works fine. I can even tunnel the port 8787 from the server to another port on my computer via ssh and get the same results.

But when I try to access this port through the server’s ip with a HTTP request, I get to see the login page, but I can’t login. I tried different auth methods but none worked. It simply reloads the page and I don’t get to start the server session.
The docker produces no error in the log tho. It only said the user logged in, but nothing happens and the page just reloads.
Here is the log file:

jupyterhub  | [I 2023-03-23 05:49:11.251 JupyterHub app:2810] Running JupyterHub version 3.1.1
jupyterhub  | [I 2023-03-23 05:49:11.251 JupyterHub app:2840] Using Authenticator: jupyterhub.auth.DummyAuthenticator-3.1.1
jupyterhub  | [I 2023-03-23 05:49:11.251 JupyterHub app:2840] Using Spawner: dockerspawner.dockerspawner.DockerSpawner-12.1.0
jupyterhub  | [I 2023-03-23 05:49:11.251 JupyterHub app:2840] Using Proxy: jupyterhub.proxy.ConfigurableHTTPProxy-3.1.1
jupyterhub  | [I 2023-03-23 05:49:11.268 JupyterHub app:1649] Loading cookie_secret from /data/jupyterhub_cookie_secret
jupyterhub  | [I 2023-03-23 05:49:11.384 JupyterHub proxy:556] Generating new CONFIGPROXY_AUTH_TOKEN
jupyterhub  | [I 2023-03-23 05:49:11.393 JupyterHub app:1969] Not using allowed_users. Any authenticated user will be allowed.
jupyterhub  | [I 2023-03-23 05:49:11.424 JupyterHub app:2879] Initialized 0 spawners in 0.004 seconds
jupyterhub  | [I 2023-03-23 05:49:11.431 JupyterHub metrics:278] Found 1 active users in the last ActiveUserPeriods.twenty_four_hours
jupyterhub  | [I 2023-03-23 05:49:11.432 JupyterHub metrics:278] Found 1 active users in the last ActiveUserPeriods.seven_days
jupyterhub  | [I 2023-03-23 05:49:11.433 JupyterHub metrics:278] Found 1 active users in the last ActiveUserPeriods.thirty_days
jupyterhub  | [W 2023-03-23 05:49:11.434 JupyterHub proxy:746] Running JupyterHub without SSL.  I hope there is SSL termination happening somewhere else...
jupyterhub  | [I 2023-03-23 05:49:11.434 JupyterHub proxy:750] Starting proxy @ http://:8000
jupyterhub  | 05:49:11.833 [ConfigProxy] info: Proxying http://*:8000 to (no default)
jupyterhub  | 05:49:11.836 [ConfigProxy] info: Proxy API at http://127.0.0.1:8001/api/routes
jupyterhub  | 05:49:12.478 [ConfigProxy] info: 200 GET /api/routes
jupyterhub  | [I 2023-03-23 05:49:12.479 JupyterHub app:3130] Hub API listening on http://jupyterhub:8080/hub/
jupyterhub  | 05:49:12.482 [ConfigProxy] info: 200 GET /api/routes
jupyterhub  | [I 2023-03-23 05:49:12.482 JupyterHub proxy:477] Adding route for Hub: / => http://jupyterhub:8080
jupyterhub  | 05:49:12.485 [ConfigProxy] info: Adding route / -> http://jupyterhub:8080
jupyterhub  | 05:49:12.486 [ConfigProxy] info: Route added / -> http://jupyterhub:8080
jupyterhub  | 05:49:12.487 [ConfigProxy] info: 201 POST /api/routes/
jupyterhub  | [I 2023-03-23 05:49:12.488 JupyterHub app:3197] JupyterHub is now running at http://:8000
jupyterhub  | [I 2023-03-23 05:49:14.099 JupyterHub log:186] 200 GET /hub/login?next=%2Fhub%2F (@::ffff:<my-local-ip>) 76.21ms
jupyterhub  | [I 2023-03-23 05:49:19.260 JupyterHub base:819] User logged in: test
jupyterhub  | [I 2023-03-23 05:49:19.261 JupyterHub log:186] 302 POST /hub/login?next=%2Fhub%2F -> /hub/ (test@::ffff:<my-local-ip>) 33.97ms
jupyterhub  | [I 2023-03-23 05:49:19.281 JupyterHub log:186] 302 GET /hub/ -> /hub/login?next=%2Fhub%2F (@::ffff:<my-local-ip>) 1.67ms
jupyterhub  | [I 2023-03-23 05:49:19.301 JupyterHub log:186] 200 GET /hub/login?next=%2Fhub%2F (@::ffff:<my-local-ip>) 2.97ms
jupyterhub  | [I 2023-03-23 05:49:22.261 JupyterHub base:819] User logged in: user
jupyterhub  | [I 2023-03-23 05:49:22.263 JupyterHub log:186] 302 POST /hub/login?next=%2Fhub%2F -> /hub/ (user@::ffff:<my-local-ip>) 17.91ms
jupyterhub  | [I 2023-03-23 05:49:22.282 JupyterHub log:186] 302 GET /hub/ -> /hub/login?next=%2Fhub%2F (@::ffff:<my-local-ip>) 1.61ms
jupyterhub  | [I 2023-03-23 05:49:22.304 JupyterHub log:186] 200 GET /hub/login?next=%2Fhub%2F (@::ffff:<my-local-ip>) 4.78ms
jupyterhub  | [I 2023-03-23 05:49:24.041 JupyterHub base:819] User logged in: admin
jupyterhub  | [I 2023-03-23 05:49:24.042 JupyterHub log:186] 302 POST /hub/login?next=%2Fhub%2F -> /hub/ (admin@::ffff:<my-local-ip>) 18.55ms
jupyterhub  | [I 2023-03-23 05:49:24.060 JupyterHub log:186] 302 GET /hub/ -> /hub/login?next=%2Fhub%2F (@::ffff:<my-local-ip>) 1.19ms
jupyterhub  | [I 2023-03-23 05:49:24.082 JupyterHub log:186] 200 GET /hub/login?next=%2Fhub%2F (@::ffff:<my-local-ip>) 3.53ms

So, what should I do to be able to access it via my local machine?

  • Does the original example work unchanged?
  • Does your modified example work if you use port 8000 instead of 8787?
  • Does the original example but using port 8787 instead of 8000 work?