Why is Traefik ignoring my wildcard TLS domain in Docker Compose?
Asked by
VelvetComet42
I'm configuring Traefik through Docker Compose and can set the main TLS domain successfully, but the wildcard subject alternative name is not being recognized. I've tried different quoting styles without success:
```yaml
command:
- --entrypoints.websecure.http.tls.domains[0].main=${MY_DOMAIN:?err}
- --entrypoints.websecure.http.tls.domains[0].sans=*.${MY_DOMAIN:?err}
```
The same domain configuration works when it is hard-coded in my static configuration file. What is the correct way to configure the wildcard domain?
Answers
Traefik only loads static configuration from one source. If youโre using a complete static configuration file such as `traefik.yml`, the `command` options in Compose wonโt be applied, even if only one section is duplicated or changed. Youโll need to put the settings in the static file or move the TLS domain configuration to the router labels.
Reply to this answer
For a Docker provider setup, define the domains on the router instead. Compose can expand the environment variable in the labels, for example:
```yaml
labels:
- traefik.http.routers.myapp.tls.domains[0].main=${MY_DOMAIN}
- traefik.http.routers.myapp.tls.domains[0].sans=*.${MY_DOMAIN}
```
The important issue isnโt the quotingโthe command flags are being ignored because Traefik is already reading its static configuration from the file.
VelvetComet42: Got it, that explains why changing the quoting had no effect. Iโll use the router labels or move the whole configuration into one static source.
Reply to this answer
Add your answer
Answers are reviewed before publication.
VelvetComet42: So the static file and the Compose command options canโt be combined? Iโll move the domain settings into the router labels and test that.