Thanks it is working !!
- I have used a bit more complex example. So the environment variable
WAN_HOSTNAME
doesn't specify the full hostname but a part of it.
http:
routers:
pi3one:
entryPoints:
- "websecure"
rule: "Host(`pi3one.{{env "WAN_HOSTNAME"}}`)"
middlewares:
- traefik_auth@docker
- add_ui_to_path
tls:
certResolver: mytlschallenge
service: pi3one
- In addition to the above you must also assure that the environment variable
WAN_HOSTNAME
is known in the traefik container. ( 2.1) For this I have defined the environment variable in the.env
file (in same folder as my docker-compose.yml) and (2.2) I have added this environment variable to mytraefik
service definition in mydocker-compose.yml
as follows:
traefik:
build: traefik
container_name: "traefik"
...
environment:
# WAN_HOSTNAME is used in traefik config.yml file !
- WAN_HOSTNAME
labels:
- "traefik.enable=true"
...