Multiple sub domains per container

I have a multi-tenant app hosted on bar.com. The tenant is determined by the host url

t1.bar.com
t2.bar.com

how can I use the labels in the container to say that this container handles *.bar.com without having to manually specify each tenant ?

I guess the rule Host(`bar.com`) should do it.

oh ! that simple ? will give that a try. Thanks !

I don't think Host(`bar.com`) will do, as that will just string match and not sub-string match.

Check HostRegexp() instead (doc):

.rule=HostRegexp(`^.+\.example\.com$`)

Be aware that Traefik will usually use Host() to generate TLS certs for the domains. So if you use HostRegexp() instead, you probably need to use Traefik LetsEncrypt dnsChallenge for a wildcard TLS cert or bring your own custom TLS cert.

2 Likes