Marcel Wolf
Marcel Wolf

Reputation: 326

Use wildcard for frontend rule in traefik configuration

I try to run a traefik as proxy in front of my docker services.

To enable this i had to add for every service a frontend rule

docker service update --label-add traefik.frontend.rule=Host:sub.domain.com

Is it possible to use a wildcard for this? A domain is not always enabled in front of the traefik, it can also be only the ip address.

Upvotes: 1

Views: 5470

Answers (2)

Marcel Wolf
Marcel Wolf

Reputation: 326

I found an answer:

# from my docker-compose.yaml service block
labels:
  - "traefik.frontend.rule=HostRegexp:{catchall:.*}"
  - "traefik.frontend.priority=1"

source:

https://www.techjunktrunk.com/docker/2017/11/03/traefik-default-server-catch-all/

Upvotes: 4

ldez
ldez

Reputation: 3128

To enable wildcard certificates you have to:

  • use the DNS Challenge
  • define a section [[acme.domains]] in your traefik.toml.
[acme]
# ...
[[acme.domains]]
  main = "*.domain.com"
  sans = ["domain.com"]
# ...

https://docs.traefik.io/configuration/acme/#wildcard-domains

If a wildcard certificate is created for a domain (and SAN) by the [[acme.domains]] block, the certificate will be used for all frontend related to this domain (i.e. the frontend's rule won't create a dedicate certificate).

Upvotes: 1

Related Questions