Quick Start: Traefik Dashboard with Custom Domain

how to configure custom domain for traefik dashboard

Quick Start: Traefik

Preparation

1
2
# create dirs and empty files
mkdir -p traefik/dynamic-conf && cd traefik && touch compose.yml traefik.yml dynamic-conf/self.yml

compose.yml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
version: Compose specification

services:
    traefik:
        image: traefik:3.0
        ports:
            - "80:80"
        environment:
            - TZ=Asia/Shanghai
        volumes:
            # /traefik.yml and /etc/traefik/traefik.yml are both available.
            - "./traefik.yml:/etc/traefik/traefik.yml"
            # dynamic-conf dir is self-defined
            - "./dynamic-conf:/etc/traefik/dynamic-conf"
            - "/var/run/docker.sock:/var/run/docker.sock:ro"
        networks:
            - traefik-net

networks:
    traefik-net:
        name: traefik-net
        ipam:
            config:
                -   subnet: 172.16.238.0/24

traefik.yml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
### Static Configuration
log:
    level: INFO
api:
    insecure: true
    dashboard: true
entryPoints:
    web:
        address: :80
providers:
    file:
        directory: /etc/traefik/dynamic-conf
        watch: true

self.yml in dir dynamic-conf

1
2
3
4
5
6
### Dynamic Configuration
http:
    routers:
        dashboard:
            rule: Host(`traefik.x.internal`)
            service: api@internal

Config DNS domain parse

If you have DNS server, please reference the DNS server guide to config it

If not - using the unix-like system: edit the /etc/hosts - using the windows: edit the C:\Windows\System32\drivers\etc\hosts

1
127.0.0.1 traefik.x.internal

Run

1
2
3
docker compose up -d
# docker compose -p traefik up -d
# docker compose -f ./compose.yml -p traefik up -d

Access: http://traefik.x.internal

Licensed under CC BY-NC-SA 4.0
Last updated on Nov 24, 2023 10:42 UTC