【发布时间】:2020-11-02 08:49:29
【问题描述】:
我可以访问单个子域 subdomain.domain.com,我在 traefik 后面运行多个服务。为了将请求路由到正确的服务器,我正在设置 traefik 路由器规则以区分 PathPrefix。
JupyterHub 是我正在运行的服务之一,我试图在“subdomain.domain.com/jupyterhub”中运行它。通过设置 c.JupyterHub.bind_url="http://:8000/jupyterhub",我可以让 JupyterHub 以这种方式工作。但是它使用 dockerspawner 生成的服务器仍在“/user/{username}”上运行,而不是在“/jupyterhub/user/{username}”上运行。我认为它必须是我必须设置的 JupyterLab 选项,但我不知道如何设置。
我的设置(相关部分):
docker-compose.yaml:
version: '3.5'
services:
jupyterhub:
build: ./jupyterhub
expose:
- 8000
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./jupyterhub/ssl.crt:/srv/jupyterhub/ssl.crt
- ./jupyterhub/ssl.key:/srv/jupyterhub/ssl.key
- /etc/hostname:/srv/jupyterhub/host_hostname:ro
networks:
- traefik_proxy
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik_proxy"
- "traefik.http.services.jupyterhub.loadbalancer.server.port=8000"
- "traefik.http.services.jupyterhub.loadbalancer.server.scheme=https"
- "traefik.http.routers.jupyterhub.entrypoints=websecure"
- "traefik.http.routers.jupyterhub.rule=Host(`subdomain.domain.com`) && (PathPrefix(`/jupyterhub`) || PathPrefix(`/hub`) || PathPrefix(`/user`))"
- "traefik.http.routers.jupyterhub.tls=true"
- "traefik.http.routers.jupyterhub.middlewares=strip-jupyterhub@docker"
- "traefik.http.middlewares.strip-jupyterhub.stripprefix.prefixes=/jupyterhub"
jupyterhub/Dockerfile:
FROM jupyterhub/jupyterhub:1.3.dev
RUN apt-get update && apt-get -y install sssd gcc python3-dev
RUN pip install dockerspawner oauthenticator PyJWT netifaces
ADD jupyterhub_config.py /srv/jupyterhub
jupyterhub/jupyterhub_config.py:
<snip>
c.DockerSpawner.image = 'jupyter/datascience-notebook:lab-2.1.1'
c.JupyterHub.bind_url = 'http://:8000/jupyterhub/'
<snip>
此设置有效,但只是因为我在 traefik 规则中添加了 PathPrefix(/user) 并且我正在使用 traefik 中间件从 URL 中删除“/jupyterhub/”。 JupyterHub 生成器将所有内容重定向到“subdomain.domain.com/user/{username}”,我不知道如何在“subdomain.domain.com/jupyterhub/user/{username}”上运行它。
【问题讨论】:
-
你有想过这个吗?我现在正在尝试做同样的事情。
标签: docker docker-compose traefik jupyter-lab jupyterhub