Traefik

From Leo's Notes
Revision as of 18:16, 26 January 2021 by Leo (talk | contribs) (→Docker)
This page was last edited on 26 January 2021, at 18:16.


Docker

The traefik docker backend is configured by labeling your docker containers.

Traefik v2

You must have separate routers for each entrypoint. Listing them as entrypoints=http,https doesn't work.

labels:
      - traefik.enable=true
      - traefik.docker.network=traefik
      # service
      - traefik.http.services.gitlab-service.loadbalancer.server.port=8888
      # https
      - traefik.http.routers.gitlab-https.entrypoints=https
      - traefik.http.routers.gitlab-https.rule=Host(`gitlab.example.com`)
      - traefik.http.routers.gitlab-https.tls=true
      - traefik.http.routers.gitlab-https.tls.certresolver=letsencrypt
      - traefik.http.routers.gitlab-https.service=gitlab-service
      # http
      - traefik.http.routers.gitlab.entrypoints=http
      - traefik.http.routers.gitlab.rule=Host(`gitlab.example.com`)
      - traefik.http.routers.gitlab.service=gitlab-service

If you wish to have http redirect to the https version, create and use a redirect middleware.

# http
      - traefik.http.routers.gitlab.entrypoints=http
      - traefik.http.routers.gitlab.rule=Host(`gitlab.example.com`)
      - traefik.http.routers.gitlab.middlewares=gitlab-https-redirect
      - traefik.http.middlewares.gitlab-https-redirect.redirectscheme.scheme=https