如何完全在traefik后面的前缀URL上运行JupyterHub / JupyterLab

问题描述

我可以访问一个子域subdomain.domain.com,在该子域上我可以在traefik后面运行多个服务。为了将请求路由到正确的服务器,我设置了traefik路由器规则以区分PathPrefix。

JupyterHub是我正在运行的服务之一,我正在尝试在“ subdomain.domain.com/jupyterhub”中运行。通过设置c.JupyterHub.bind_url =“ http://:8000 / jupyterhub”,我可以让JuptyerHub这样工作。但是它与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}”上运行它。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...