The names web and websecure are the default names used in documentation. They have to be defined in Traefik static config traefik.yml or command: for the entrypoints. Compare to simple Traefik example.
Static certificates loaded via tls in Traefik dynamic config will automatically be used, when you set tls=true or tls: {} globally on entrypoint or on every router. They are matched via Host().
Traefik labels on a Docker service/container will always target itself. You can't set a different target service/container.
Some experiments with the Docker labels for routers and services:
Single router and service works, even with different names:
labels:
- traefik.enable=true
- traefik.http.routers.mywhoami1.rule=Host(`whoami-1.example.com`)
- traefik.http.services.mywhoami100.loadbalancer.server.port=8080
Simple using multiple routers and services does not work, even with the same name:
labels:
- traefik.enable=true // DOES NOT WORK
- traefik.http.routers.mywhoami2.rule=Host(`whoami-2.example.com`)
- traefik.http.services.mywhoami2.loadbalancer.server.port=8080
- traefik.http.routers.mywhoami3.rule=Host(`whoami-3.example.com`)
- traefik.http.services.mywhoami3.loadbalancer.server.port=8080
When there are multiple routers and services, you need to assign them to work:
labels:
- traefik.enable=true
- traefik.http.routers.mywhoami4.rule=Host(`whoami-4.example.com`)
- traefik.http.routers.mywhoami4.service=mywhoami4
- traefik.http.services.mywhoami4.loadbalancer.server.port=8080
- traefik.http.routers.mywhoami5.rule=Host(`whoami-5.example.com`)
- traefik.http.routers.mywhoami5.service=mywhoami5
- traefik.http.services.mywhoami5.loadbalancer.server.port=8080
With multiple routers and only a single service, the simplified version works, too:
labels:
- traefik.enable=true
- traefik.http.routers.mywhoami6.rule=Host(`whoami-6.example.com`)
- traefik.http.routers.mywhoami7.rule=Host(`whoami-7.example.com`)
- traefik.http.services.mywhoami67.loadbalancer.server.port=8080
So the general rule for Traefik Docker labels is (probably):
- When 1
serviceexists, it is automatically assigned to allrouters- When multiple
servicesexist, everyrouterneeds aserviceexplicitly assigned- Names of
routersandservicesdo not matter