Hi,
TLDR above
I do have it all working together, below are snippets from my docker compose for reference. The solution for me was to not try and do anything with the automatic stuff from Traefik. Instead I have gone all in with a āmacvlanā (details below, itās not pretty) - but it helped me get all of the network broadcast features working correctly with HA (many more caveats below to make all of this work).
The actual HA config:
homeassistant:
image: homeassistant/home-assistant:stable
command:
[ "python3", "-m", "homeassistant", "--log-rotate-days", "600", "--log-file", "/logs/home-assistant.log", "--config", "/config" ]
depends_on:
- postgres
- mqtt
healthcheck:
test: ["CMD", "ping", "-c", "2", "hass.sf"]
volumes:
- /tank/share/docker/hass/config:/config
- /tank/share/logs/hass:/logs
- "/etc/localtime:/etc/localtime:ro"
environment:
- TZ=Australia/Brisbane
restart: always
networks:
macbridge:
ipv4_address: 10.1.1.1
You can probably ignore the health check (note the hostname is something I have configured on my internal DNS server, it helps detect when DNS stops resolving in HA). I have also modified the command so my logs actually rotate (as I keep HA in full debug mode all the time). I then have an external tool do the log move/rotate and delete (hence the 600
days). Obviously all paths need to be setup to suit your server.
This is the Traefik config:
traefik:
image: "traefik:2.2"
networks:
- traefik-net
ports:
- "80:80"
- "443:443"
- "8888:8080"
restart: always
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- /tank/share/docker/core/traefik/traefik.toml:/etc/traefik/traefik.toml
- /tank/share/docker/core/traefik/config/:/config/
- /tank/share/store/traefik/certs/:/certs/
- "/etc/localtime:/etc/localtime:ro"
environment:
XXX your config here for DNS auth of SSL certs
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.entrypoints=web-secure"
- "traefik.http.services.traefik-service.loadbalancer.server.port=8080"
- "traefik.http.routers.traefik.tls.certresolver=letsencrypt"
- "traefik.http.routers.traefik.middlewares=magicauth@file"
Note I have a loopback config (via labels) to access the Traefik UI over HTTPS.
This in the config file (/config/hass.toml
) I have in Traefik for HA,
[http]
# Add the router
[http.routers]
[http.routers.router0]
entryPoints = ["web-secure"]
service = "hass"
rule = "Host(`XXX`)"
[http.routers.router0.tls]
certResolver = "letsencrypt"
# Add the service
[http.services]
[http.services.hass]
[http.services.hass.loadBalancer]
[[http.services.hass.loadBalancer.servers]]
url = "http://hass.sf:8123/"
And in my main traefik.toml
I have the following snippets:
[entryPoints]
[entryPoints.web]
address = ":80"
[entryPoints.web-secure]
address = ":443"
[api]
insecure = true
[file]
watch = true
[providers]
[providers.file]
directory = "/config"
watch = true
[log]
level = "INFO"
[serversTransport.forwardingTimeouts]
idleConnTimeout = "1s"
[certificatesResolvers.letsencrypt.acme]
email = XXX
storage = "/certs/acme.json"
[certificatesResolvers.letsencrypt.acme.dnsChallenge]
provider = "godaddy"
Again, note the internal DNS name (hass.sf
), this could just be an IP address.
Now the real fun if working with a macvlan
network (named macbridge
) - it can not be on the same network interface as your Traefik/default interface. My server happens to have 2x NICās, and they are both plugged into the LAN. One does not have an IP address, rather it is just brought up at boot with out an IP. I then have this in my docker-compose file:
macbridge:
external:
name: macbridge
And I manually created the macbridge
network running the following command (you canāt have this in docker compose becauseā¦ I donāt know - it was removed/never implemented in v3 compose files):
docker network create -d macvlan --subnet=10.1.0.0/16 --ip-range=10.1.1.0/24 --gateway=10.1.255.254 -o parent=enp4s0f1 macbridge
I have obviously sectioned off the 10.1.1.0/24
portion of the network for macvlan
hosts - youāll probably only need to allocate a couple of IP addresses.
My ādefaultā network interface on the server is enp4s0f0
, and any communication between Traefik and HA is done over the LAN.
Hope that helps / makes some sense (it was an utter nightmare to get it all going!) - let me know if anything does not make sense.
Good luck!