Sub-level subdomains TLS not working

Hi there!

So I'm using redis to automatically create configurations, but sub-level subdomains (e.g. files.home.myhost.com) are not working with TLS, so the traefik default cert is returned. Normal 1-level subdomains like files.myhost.com are working perfectly. HTTP works on both 1-level-subdomains and n-level-subdomains.

I'm creating the configuration like this:

redis-cli set traefik/http/services/$NAME/loadbalancer/servers/0/url http://127.0.0.1:$REMOTE_PORT/
redis-cli set traefik/http/routers/$NAME/rule Host\(\\\`$HOST.myhost.com\\\`\)
redis-cli set traefik/http/routers/$NAME/service $NAME

For $NAME I simply use the subdomain (e.g. files.home)

traefik.yml
log:
  level: "INFO"

entryPoints:
  http:
    address: ":80"
    # http:
    #   redirections:
    #     entryPoint:
    #       to: "https"
    #       scheme: "https"
  https:
    address: ":443"
    http:
      tls:
        certResolver: letsencrypt
        domains:
          - main: "MYHOST"
            sans: ["*.MYHOST"]

certificatesResolvers:
  letsencrypt:
    acme:
      email: "MYMAIL"
      storage: "/opt/traefik/acme.json"
      #caServer: "https://acme-staging-v02.api.letsencrypt.org/directory"
      dnsChallenge:
        provider: luadns
        delayBeforeCheck: 10

api:
  dashboard: true
#   insecure: true

providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
    exposedByDefault: false
  redis:
    endpoints:
      - "127.0.0.1:6379"
    tls:
      insecureSkipVerify: true

http:
  routers:
    default:
      service: "api@internal"
      entrypoints: ["http"]
    default-secure:
      service: "api@internal"
      entrypoints: ["https"]

When I look at the traefik dashboard, everything looks OK.

What am I doing wrong? Thanks for your help!

Why do you have this part in traefik.yml? You router Host includes the full domain, right?

Yup, the rule includes my domain.

I thought the part you quoted is needed for LetsEncrypt to know for which domain name the certificate should be issued.

But LetsEncrypt is working as intended, only sub-level subdomains aren't correctly handled by traefik.

Did you remove the quoted part and try again?

Yes I did, sadly the problem still persists.

Enable Traefik debug and check the logs, look for LetsEncrypt errors.