Traefik automatically add sub-domains?

I’m using Traefik as a reverse proxy. I now want to add sub-domains automatically without having to manually edit my .yml files and docker-compose it up.

Can I change this file automatically:
static yml config file for traefik to make sub-domains:

http:
  routers:
    example:
      service: example
      rule: "Host(`sub1.example.com`)"
      tls:
        certResolver: leresolver
  services:
    example:
      loadBalancer:
        servers:
          - url: "http://example.com:34102/"

To something like this?

    http:
      routers:
    example:
      service: example
      rule: "Host(`sub1.example.com`)"
      tls:
        certResolver: leresolver
    newCustomer:
      service: newCustomer
      rule: "Host(`newcustomer.example.com`)"
      tls:
        certResolver: leresolver
      services:
    example:
      loadBalancer:
        servers:
          - url: "http://example.com:34102/"
    newCustomer:
      loadBalancer:
        servers:
          - url: "http://example.com:34102/"

Is there a way to do this? Perhaps I can make a API or Webhook request for this where it will send a subdomain name for my client to my server (with ssh or tls?) and edit my yml file and restart my traefik docker container?

You can use regex to match subdomains.

Search for:

HostRegexp

Traefik supports wildcard domains, so I don’t think you’ll need to be rewriting your yml file for each domain, as long as your DNS host is one of the supported platforms. A wildcard domain validation is only supported using the dns method.

A list of the supported providers is here:
https://doc.traefik.io/traefik/https/acme/#dnschallenge

Just remember that after you manually edit the yml, Wappler will overwrite it if you save new target settings.

I’ve been investigating for the last hour about traefik, ssl, cnames and all the stuff you need to create a white label custom domain solution.

This article seems like a good start.

Once you assign a subdomain to a client you can instruct them to add a CNAME to your subdomain.