Traefik and Home Assistant

Hi guys! I was able following the https://www.smarthomebeginner.com guide to setup Traefik on my domain and I can access Traefik and pi hole from the outside!
But unfortunately I can’t forward HA to Traefik, I’m using the network_mode host and I’m trying to use the backends and frontends but I can’t in anyway see my “custom configuration” to Traefik web interface.

Here’s my Docker-compose

version: '3'
services:
  traefik:
    hostname: traefik
    image: traefik:v1.7.16
    container_name: traefik
    restart: always
    domainname: ${DOMAINNAME}
    networks:
      - default
      - traefik_proxy
    ports:
      - "80:80"
      - "443:443"
#      - "8000:8080"
    environment:
      - CF_API_EMAIL=${CLOUDFLARE_EMAIL}
      - CF_API_KEY=${CLOUDFLARE_API_KEY}
    labels:
      - "traefik.enable=true"
      - "traefik.backend=traefik"
      - "traefik.frontend.rule=Host:traefik.${DOMAINNAME}"
#      - "traefik.frontend.rule=Host:${DOMAINNAME}; PathPrefixStrip: /traefik"
      - "traefik.port=8080"
      - "traefik.docker.network=traefik_proxy"
      - "traefik.frontend.headers.SSLRedirect=true"
      - "traefik.frontend.headers.STSSeconds=315360000"
      - "traefik.frontend.headers.browserXSSFilter=true"
      - "traefik.frontend.headers.contentTypeNosniff=true"
      - "traefik.frontend.headers.forceSTSHeader=true"
      - "traefik.frontend.headers.SSLHost=example.com"
      - "traefik.frontend.headers.STSIncludeSubdomains=true"
      - "traefik.frontend.headers.STSPreload=true"
      - "traefik.frontend.headers.frameDeny=true"
      - "traefik.frontend.auth.basic.users=${HTTP_USERNAME}:${HTTP_PASSWORD}"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ${USERDIR}/traefik:/etc/traefik
      - ${USERDIR}/shared:/shared
  homeassistant:
    container_name: homeassistant
    restart: always
    image: homeassistant/home-assistant
    volumes:
      - /home/giacomo/dont:/config
      - /etc/localtime:/etc/localtime:ro
    privileged: true
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}
    network_mode: host
  pihole:
    container_name: pihole
    domainname: docker
    hostname: pihole
    image: pihole/pihole:latest
    ports:
      - '53:53/tcp'
      - '53:53/udp'
      # - '67:67/udp'
      - '8182:80'
      - '8183:443'
    restart: unless-stopped
    volumes:
      - ${USERDIR}/pihole/pihole:/etc/pihole
      - ${USERDIR}/pihole/pihole.log:/var/log/pihole.log
      - ${USERDIR}/pihole/dnsmasq.d:/etc/dnsmasq.d
    environment:
      - ServerIP=192.168.1.159
      - PROXY_LOCATION=pihole
      - VIRTUAL_HOST=pihole.${DOMAINNAME}
      - VIRTUAL_PORT=80
      - TZ=${TZ}
      - WEBPASSWORD=PASSWORD
      - DNS1=1.0.0.1
      - DNS2=1.1.1.1
    labels:
      - "traefik.enable=true"
      - "traefik.backend=pihole"
      - "traefik.port=80"
      - "traefik.frontend.rule=HostRegexp:pihole.${DOMAINNAME},{catchall:.*}"
      - "traefik.frontend.priority=1"
      - traefik.frontend.headers.SSLRedirect=true
      - traefik.frontend.headers.STSSeconds=315360000
      - traefik.frontend.headers.browserXSSFilter=true
      - traefik.frontend.headers.contentTypeNosniff=true
      - traefik.frontend.headers.forceSTSHeader=true
      - traefik.frontend.headers.SSLHost=${DOMAINNAME}
      - traefik.frontend.headers.STSIncludeSubdomains=true
      - traefik.frontend.headers.STSPreload=true
      - traefik.frontend.headers.frameDeny=true

networks:
  traefik_proxy:
    external:
      name: traefik_proxy
  default:
    driver: bridge

Here’s my Traefik.toml

logLevel = "DEBUG" #DEBUG, INFO, WARN, ERROR, FATAL, PANIC
defaultEntryPoints = ["http", "https"]
InsecureSkipVerify=true
# WEB interface of Traefik - it will show web page with overview of frontend and backend configurations 
[api]
  entryPoint = "traefik"
  dashboard = true
  address = ":8080"

# Force HTTPS
[entryPoints]
  [entryPoints.http]
  address = ":80"
    [entryPoints.http.redirect]
    entryPoint = "https"
  [entryPoints.https]
  address = ":443"
    [entryPoints.https.tls]

[traefikLog]
filePath="/etc/traefik/traefik.log"

[file]
  watch = true
  filename = "/etc/traefik/rules.toml"

# Let's encrypt configuration
[acme]
email = "EMAIL" #any email id will work
storage="/etc/traefik/acme/acme.json"
entryPoint = "https"
acmeLogging=true
onDemand = false #create certificate when container is created
[acme.dnsChallenge]
  provider = "cloudflare"
  delayBeforeCheck = 300
[[acme.domains]]
   main = "DOMAIN.tk"
[[acme.domains]]
   main = "*. DOMAIN.tk"


# Connection to docker host system (docker.sock)
[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "DOMAIN.tk"
watch = true
# This will hide all docker containers that don't have explicitly  
# set label to "enable"
exposedbydefault = false

And finally my rules.toml

[backends]
  [backends.backend-pihole]
    [backends.backend-pihole.servers]
      [backends.backend-pihole.servers.server-pihole-ext]
        url = "http://192.168.1.159:8123"
        weight = 0

[frontends]
  [frontends.frontend-pihole]
    backend = "backend-pihole"
    passHostHeader = true
#    basicAuth = [
#      HTTP Authentication
#      "xxx:yyyyyyyyyyyy",
#    ]
    [frontends.frontend-pihole.routes]
          [frontends.frontend-pihole.routes.route-pihole-ext]
        rule = "Host:DOMAIN.tk"

Could someone please help me?? I’m becoming crazy

  homeassistant:
    container_name: homeassistant
    image: homeassistant/home-assistant
    restart: unless-stopped
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./homeassistant:/config
    ports:
      - 8123:8123
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}
    labels:
      - traefik.backend=homeassistant
      - traefik.frontend.rule=Host:homeassistant.${DOMAIN}
      - traefik.frontend.headers.frameDeny=false
    network_mode: 'host'
    devices:
      - /dev/zwave:/dev/zwave
 [file]
 [backends]
   [backends.backend-homeassistant]
     [backends.backend-homeassistant.servers]
       [backends.backend-homeassistant.servers.server-homeassistant-ext]
         url = "http://192.168.0.xxx:8123"
         weight = 0
 [frontends]
   [frontends.frontend-homeassistant]
     backend = "backend-homeassistant"
     passHostHeader = true
     [frontends.frontend-homeassistant.routes]
       [frontends.frontend-homeassistant.routes.route-homeassistant-ext]
       rule = "Host:hass.example.com"
1 Like
  - traefik.frontend.headers.frameDeny=false

Why is this needed? Could you please explain me? I am looking into headers that need to be set in order for HA to play nicely.