version: '3.7'
services:
traefik:
image: traefik:v2.2.0
container_name: traefik
command:
- --log.level=INFO
- --log.filePath=etc/traefik/log/traefik.log
- --accessLog.filePath=etc/traefik/log/access.log
- --accessLog.bufferingSize=100
- --providers.docker=true
- --providers.docker.exposedbydefault=false
- --api
- --api.insecure=true
- --entrypoints.traefik.address=:8888
- --entrypoints.web.address=:80
- --entrypoints.web.http.redirections.entrypoint.to=websecure
- --entrypoints.web.http.redirections.entrypoint.scheme=https
- --entrypoints.websecure.address=:443
- --entrypoints.websecure.http.tls.certresolver=myresolver
- --certificatesresolvers.myresolver.acme.dnschallenge=true
- --certificatesresolvers.myresolver.acme.email=${CF_API_EMAIL}
- --certificatesresolvers.myresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory
- --certificatesresolvers.myresolver.acme.storage=acme.json
- --certificatesresolvers.myresolver.acme.dnschallenge.provider=cloudflare
ports:
- 80:80
- 443:443
- 8888:8888
environment:
- CF_API_EMAIL=${CF_API_EMAIL}
- CF_API_KEY=${CF_API_KEY}
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./traefik/acme.json:/acme.json
- ./traefik/:/etc/traefik/log/
labels:
traefik.enable: true
# Dashboard
traefik.http.routers.traefik.rule: Host(`traefik.mydomain.com`)
traefik.http.routers.traefik.entrypoints: websecure
traefik.http.routers.traefik.service: api@internal
traefik.http.routers.traefik.middlewares: auth
traefik.http.middlewares.auth.basicauth.users: user:$$apr1$$gnc3F4mv$$VNr.mLwolbwUF6vYVzPVs0
homeassistant:
container_name: homeassistant
image: homeassistant/home-assistant:latest
volumes:
- './HA/:/config'
- /etc/localtime:/etc/localtime:ro
restart: always
labels:
traefik.enable: true
traefik.http.routers.hasss.rule: Host(`ha.mydomain.com`)
traefik.http.routers.hasss.entrypoints: websecure
traefik.http.services.hasss.loadbalancer.server.port: 8123
-
Traefik UI:
- http://localhost:8888 (without basic auth)
- https://traefik.mydomain.com (and http://traefik.mydomain.com redirect to https://traefik.mydomain.com)
-
Home assistant
- https://ha.mydomain.com (and http://ha.mydomain.com redirect to https://ha.mydomain.com)