Enable HTTPS for Traefik dashboard

I want to access Traefik dashboard on port 9000 using HTTPS. If I access whoami website on port 5000, HTTPS works as it should. How can I make HTTPS work for dashboard on port 9000 as well? Here is my configuration:

docker-compose-traefik.yml

version: "3.7"

services:
  traefik:
    image: "traefik:v2.0"
    networks:
      - traefik-net
    ports:
      - "9000:9000"
      - "5000:5000"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
      - "./config/:/etc/traefik/"
      - "./cert/:/cert/"
    deploy:
      replicas: 1
      labels:
        - "traefik.enable=true"
        - "traefik.http.routers.traefik.rule=Host(`example.com`)"
        - "traefik.http.routers.traefik.entrypoints=traefik"
        - "traefik.http.routers.traefik.tls=true"
        - "traefik.http.services.traefik.loadbalancer.server.port=8080"

networks:
  traefik-net:
    external: true
    name: traefik-net

docker-compose-whoami.yml

version: "3.7"

services:
  whoami:
    image: "jwilder/whoami"
    networks:
      - traefik-net
    deploy:
      replicas: 3
      labels:
        - "traefik.enable=true"
        - "traefik.http.routers.whoami.rule=Host(`example.com`)"
        - "traefik.http.routers.whoami.entrypoints=web"
        - "traefik.http.routers.whoami.tls=true"
        - "traefik.http.services.whoami.loadbalancer.server.port=8000"
        - "traefik.http.services.whoami.loadbalancer.sticky=true"
        - "traefik.http.services.whoami.loadbalancer.sticky.cookie.name=StickyCookie"
        - "traefik.http.services.whoami.loadbalancer.sticky.cookie.secure=true"

networks:
  traefik-net:
    external: true
    name: traefik-net

config/traefik.yml

log:
  level: DEBUG

api:
  insecure: true
  dashboard: true

providers:
  file:
    directory: "/etc/traefik"
    watch: true
  docker:
    swarmMode: true
    exposedByDefault: false

entrypoints:
  traefik:
    address: ":9000"
  web:
    address: ":5000"

config/dynamic_conf.yml

tls:
  certificates:
    - certFile: /cert/example.com.cert
      keyFile: /cert/example.com.key

You need to use api@internal to reference the dashboard service.

There is a working example here that exposes the dashboard, that you might want to refer to.

1 Like