Hostregexp for All subdomains

Hello @knock,

Based on the Routers section of our documentation: (https://docs.traefik.io/v2.1/routing/routers/#rule), you can use:

HostRegexp(`subdomain.domain.com`,`{subhost:[a-z]+}.subdomain.domain.com`)

But note that regex only works with lowercase letters.

You can use: {subhost:[a-zA-Z0-9-]+} to select capitals and numbers and dashes in your host.

I would avoid matching a period, as you may find issues down the road when you enable TLS (as a certificate for *.example.com will match www.example.com but not `test.www.example.com)

1 Like