Hello all,
I’m having some issues setting up Home Assistant with Docker-Compose & Traefik. I have everything working including Home Assistant container being network mode host. The only problem I face now is that my proxy changes IP addresses once in a while, so when I restart Home Assistant, I have to whitelist the proxy anytime it changes. Does anyone have a solution to this? Here is my Home Assistant configuration and Docker Compose file.
configuration.yaml
# Set up for use with Traefik reverse proxy.
http:
use_x_forwarded_for: true
trusted_proxies:
- 192.168.192.2 # Add the IP address of the proxy server
- 192.168.224.3
docker-compose.yml
version: '3'
services:
homeassistant:
container_name: homeassistant
image: ghcr.io/home-assistant/home-assistant:stable
volumes:
- ./homeassistant/config:/config
- /etc/localtime:/etc/localtime:ro
restart: unless-stopped
privileged: true
network_mode: host
labels:
- "traefik.enable=true"
- "traefik.http.routers.hahttp.rule=Host(`DOMAIN.com`)"
- "traefik.http.routers.ha.rule=Host(`DOMAIN.com`)"
- "traefik.http.routers.ha.tls=true"
- "traefik.http.routers.ha.tls.certresolver=le"
- "traefik.http.routers.ha.tls.domains[0].main=DOMAIN.com"
- "traefik.http.services.homeassistant.loadbalancer.server.port=8123"
traefik:
container_name: traefik
# The official v2 Traefik docker image
image: traefik:v2.8
command:
- "--api.dashboard=true"
- "--api.insecure=true"
- "--accesslog=true"
- "--providers.docker"
- "--providers.docker.exposedbydefault=false"
- "--entryPoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--certificatesresolvers.le.acme.tlschallenge=true"
- "--certificatesresolvers.le.acme.email=EMAIL"
- "--certificatesresolvers.le.acme.storage=/letsencrypt/acme.json"
ports:
- 80:80
- 8080:8080
- 443:443
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./letsencrypt:/letsencrypt"
extra_hosts:
- host.docker.internal:172.17.0.1
As you can see in my Home Assistant configuration, those are the two IP addresses primarily used as a proxy, but I feel like that is not how it should be.