Priority and https (LE)

Hello!

I host a bunch of sites on docker behind a traefik reverse proxy, using letsencrypt to provide https for them. This all works perfectly smoothly using a combination of command line arguments and docker labels, general setup goes on the traefik command line/labels and the host-specific config goes in the container compose file, generally something on the line of:

    labels:
      - "traefik.http.routers.example.rule=Host(`www.example.com`) || Host(`example.com`)"
      - "traefik.http.routers.example.tls=true"
      - "traefik.http.routers.example.tls.certresolver=le"
      - "traefik.http.routers.example.entryPoints=https"
      - "traefik.http.routers.example.middlewares=redirect-to-www"

      - "traefik.http.routers.example80.rule=Host(`www.example.com`) || Host(`example.com`)"
      - "traefik.http.routers.example80.entryPoints=http"
      - "traefik.http.routers.example80.middlewares=redirect-to-www,redirect-to-https"

However, I have a large update upcoming that will affect all sites and I want to place a simple notice to any visitors that we're currently having some maintenance.

I was easily able to do this for http by giving a new container with a maintenance page labels that gives it priority over everything else:

    labels:
      - "traefik.http.routers.maintenance.rule=HostRegexp(`.*`)"
      - "traefik.http.routers.maintenance.priority=2000"
      - "traefik.http.services.maintenance.loadbalancer.server.port=8001"

However, this only works for http, my attempts to use a second route like I usually do to the container to catch https-traffic have all failed, presumably because traefik can't extract a hostname to construct a LE request for the container and thus just ignores the https part (and in this case, I would much prefer it to re-use the existing certificate for the "masked" host).

Is there a way of accomplishing this, or should I try to think of something else?

Are you setting a default entrypoint in static config? Have you tried:

    labels:
      - "traefik.http.routers.maintenance.rule=HostRegexp(`.*`)"
      - "traefik.http.routers.maintenance.priority=2000"
      - "traefik.http.routers.maintenance.entryPoints=http,https"
      - "traefik.http.services.maintenance.loadbalancer.server.port=8001"

Thanks for replying, but while I was waiting to have my post approved, I got it working (always happens, doesn't it). The magic incantation turned out to be:

    labels:
      - "traefik.http.routers.maintenance.rule=HostRegexp(`.*`)"
      - "traefik.http.routers.maintenance.priority=2000"
      - "traefik.http.routers.maintenance.entryPoints=http"
      - "traefik.http.routers.maintenance.service=maintenance"
      - "traefik.http.services.maintenance.loadbalancer.server.port=8001"

      - "traefik.http.routers.maintenance-https.rule=HostRegexp(`.*`)"
      - "traefik.http.routers.maintenance-https.tls=true"
      - "traefik.http.routers.maintenance-https.priority=2000"
      - "traefik.http.routers.maintenance-https.entryPoints=https"
      - "traefik.http.routers.maintenance-https.service=maintenance-https"
      - "traefik.http.services.maintenance-https.loadbalancer.server.port=8001"

I think the important bit is traefik.http.routers.*.service. Now everything magically just works.

I recall trying multiple values to entryPoints, but that didn't do it. Having ...tls=true set is probably crucial. I do not set a default entrypoint in the static config.

Cheers!