JupyterLab behind traefik reverse proxy


I’m getting a 502 response and just a page that says “Bad Gateway” when trying to access JupyterLab behind a reverse proxy (https://lab.example.com). I’ve tried reading through the documentation on JupyterLab and JupyterHub about configuring it for a reverse proxy but I must be missing something.

There are specific examples for how to do it with nginx or Apache for JupyterHub but nothing equivalent for JupyterLab. Does anybody have any suggestions for how to debug the problem?

If it helps, here are the labels I’m using for Traefik in docker-compose.

  - "8889:8888"
  traefik.port: 8889
  traefik.frontend.rule: Host:lab.${DOMAINNAME}
  traefik.frontend.headers.SSLHost: lab.${DOMAINNAME}
  traefik.docker.network: traefik_proxy
  traefik.frontend.passHostHeader: "true"
  traefik.frontend.headers.SSLForceHost: "true"
  traefik.frontend.headers.SSLRedirect: "true"
  traefik.frontend.headers.browserXSSFilter: "true"
  traefik.frontend.headers.contentTypeNosniff: "true"
  traefik.frontend.headers.forceSTSHeader: "true"
  traefik.frontend.headers.STSSeconds: 315360000
  traefik.frontend.headers.STSIncludeSubdomains: "true"
  traefik.frontend.headers.STSPreload: "true"
  traefik.frontend.headers.customResponseHeaders: X-Robots-Tag:noindex,nofollow,nosnippet,noarchive,notranslate,noimageindex
  traefik.frontend.headers.frameDeny: "true"
  traefik.frontend.headers.customFrameOptionsValue: 'allow-from https:${DOMAINNAME}'

Also, I’ve been playing around with some of the Jupyter Server settings to no avail. Here was my latest attempt:

c.ServerApp.ip = ''
c.ServerApp.port = 8888
c.ServerApp.open_browser = False
c.ServerApp.trust_xheaders = True
c.ServerApp.allow_origin= '*'
c.ServerApp.custom_display_url = 'https://lab.example.org'


Well after being stuck on this for a long time I figured it out 5 minutes after posting this. I’ll leave it up in case anybody else runs into this.

The problem was that “traefik.port: 8889” should have been “traefik.port: 8888”.