I have a case where I can't modify my docker containers run / compose command so I am unable to add labels for Traefik the "normal" way.
Questions is - can I somehow add these labels in my Traefik config.toml file - or some alternativ.
I am using Traefik 2.4.7
My labels I wanted to add to my container is:
labels:
- "traefik.enable=true"
- "traefik.http.routers.homeassistant.rule=Host(`ha.mydomain.com`)"
- "traefik.http.routers.homeassistant.entrypoints=websecure"
- "traefik.http.routers.homeassistant.tls=true"
- "traefik.http.services.homeassistant.loadbalancer.server.port=8123"
- "traefik.http.routers.homeassistant.service=homeassistant"
Hello,
The labels are part of the dynamic configuration so you can try to execute an imperative command docker service update <service-name> --label-add
I haven't tested that, so you can try it. Let us know
Based on the errors I get from that, it seems thats only for a Swarm
@jakubhajek - isn't there are way that only includes doing the change in the Traefik configuration?
You can try to create the dynamic configuration according to this example:
[http]
[http.routers]
[http.routers.redirecttohttps]
entryPoints = ["web"]
middlewares = ["https-redirect"]
rule = "HostRegexp(`{host:.+}`)"
service = "noop"
[http.routers.router0]
entryPoints = ["websecure", "web"]
middlewares = ["https-redirect", "security-headers"]
service = "b1"
rule = "Host(`sm.aele8noh.4static.pl`)"
[http.routers.router0.tls]
#certResolver = "le"
options = "default"
[http.routers.router1]
entryPoints = ["websecure", "web"]
middlewares = ["https-redirect", "security-headers"]
This file has been truncated. show original
and try to point the server to the Homassistant port if it is reachable / exposed.
However, I've not tested that kind of setup.
The recommended solution is to use labels on a service level but I understand that there is no way to restart the running container.
Thanks,
I gave it a try - but is seems that I just get a 404
[http]
[http.routers]
[http.routers.router0]
entryPoints = ["websecure", "web"]
middlewares = ["https-redirect", "security-headers"]
service = "homeassistant"
rule = "Host(ha.mydomain.com
)"
[http.routers.router0.tls]
#certResolver = "le"
options = "default"
[http.services]
[http.services.homeassistant]
[http.services.homeassistant.loadBalancer]
[[http.services.homeassistant.loadBalancer.servers]]
url = "http://localhost:8123"
Any new ideas on what to do ?