Search code examples
dockerdocker-swarmlets-encrypttraefik

CNAME redirect and lets encrypt for traefik


I have set up docker swarm with traefik. It is working well.

My DNS setup is like this

A - prod.example.com - myip

CNAME - *.prod.example.com - prod.example.com

A - realname.example.com - myip

and in traefik.toml I have entries for several domains

```

[[acme.domains]]
   main = "prod.example.com"
[[acme.domains]]
   main = "one.prod.creatomus.com"
[[acme.domains]]
   main = "two.prod.creatomus.com"
[[acme.domains]]
   main = "realname.creatomus.com"

```

and in frontend they are defined as all three domains work fine and point to the same frontend

traefik.frontend.rule=Host:one.prod.example.com, two.prod.example.com, realname.example.com

All the domains work and are redirected from 80 to 443. but somehow letsencrypt certs are fetched only for wildcard domains under *.prod.example.com.

Is it possible to use custom domain this way?

How else can I achieve letsencrypt certs for the domain realname.example.com if I can't attach wildcard CNAME to the top domain?

p.s. CNAME instead of A pointer also was not working.


Solution

  • After removing debug mode I noticed that lets encrypt ratelimit had kicked in. Probably I had missed it previously, as nothing else I changed could have made any impact. Now it is all working with the setup described above. [[acme.domains]] is not even required, as all the domains are picked up from frontend rules.