Dynamic routes and certificates for white label domains

Hello,

I am looking for some input as I just recently started using Traefik.

Current Situation

At the moment, I using docker compose to run a simple NextJS application with Traefik as a reverse proxy. Port 80 redirects to port 443 which uses Let's Encrypt.

Task

I am planning a white label feature so that customers can resell the same service using their own domain. The current idea is:

  1. Every customer automatically gets assigned a subdomain (based on username, id, ...).
  2. They would then be asked to name their own domain.
  3. Instructions to create a CNAME record for said domain pointing to the assigned subdomain would follow.
  4. Once the record has propagated, I would create a Let's Encrypt certificate for their domain.

Idea

What's the best way to automate said task? My current idea is:

  1. Add another NodeJS service which reads the assigned subdomains and respective customer domains from the database.
  2. Ignore domains which do not yet ping to my server.
  3. In Docker, I would then share the traefik.yml configuration file with said service and update it on the fly.

Questions

  1. Is there a better way to achieve said task?
  2. Once I have updated the traefik.yml, what's the best way to instruct the Traefik container to reload the configuration?

Any input is appreciated, thanks.

Still haven't found a solution for this. Any help would be much appreciated.