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?

Community Page
Last updated: