Hello, I'm implementing a common multi-env multi-services setup using Traefik as the main reverse proxy, on Docker Swarm, and using service labels to define routing.
Of course, when configured correctly, everything works well.
Unfortunately, I find myself repeating, on each Docker Swarm service, the same king of labels
- traefik.http.routers.{ENV+SERVICE}.tls=true
- traefik.http.routers.{ENV+SERVICE}.tls.certresolver=letsencrypt
- traefik.http.services.{ENV+SERVICE}.loadbalancer.server.port=80
- traefik.http.routers.{ENV+SERVICE}.middlewares=int6-test
- traefik.http.middlewares.{ENV+SERVICE}.stripprefixregex.regex=/[^/]+/
This is a lot of redundancy. hopefully, I can already factorise defaultRule on Traefik configuration itself with templating:
- --providers.docker.defaultRule=Host(`{{ index .Labels "com.docker.stack.namespace" }}.${DOMAIN}`) && PathPrefix(`/{{ index .Labels "service.name" }}/`)
But I'd like to have the same factorisation ability to avoid repeating labels on each and every stack, every service:
I want TLS activated on every router
my certresolveris always the same letsencrypt
the middleware config is always the same: stripping the first part of the path
etc
Any idea how I could simplify everything ?
Thanks !