I am trying to configure my docker containers to use SSL with a revers proxy. Take a look at my config and see what I am doing wrong. On my router I have ports 80 and 443 forwarded to my vm containing the containers. I just need to edit my docker-compose file to add HA and have it severed up with SSL. any suggestions?
1. Create traefik.toml file in location of your preference, you have to set this in the docker-compose.yml
2. Create acme.json file in location of your preference, you have to set this in the docker-compose.yml
"touch /var/data/traefik/acme.jsonchmod 600 /var/data/traefik/acme.json"
This is the content of my traefik.toml file.
#Enable logging
debug = true
logLevel = "DEBUG"
#Set default entrypoint
defaultEntryPoints = ["http", "https"]
#Redirect http to https
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.http.redirect]
entryPoint = "https"
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
[retry]
#lets encrypt http challange
[acme]
email = "your@mail"
storage = "acme.json"
entryPoint = "https"
OnHostRule = true
[acme.httpChallenge]
entryPoint = "http"
3. I am using docker-compose.yml for my containers, this is the config of both HASS and Traefik.
4. I also have a .env file for my environmental variables like {DOMAIN} etc https://docs.docker.com/compose/env-file/#syntax-rules
version : '3'
services:
########################traefik########################
traefik:
image: traefik:latest
command: --web --docker --docker.watch --docker.domain=${DOMAIN} --docker.exposedbydefault=false
container_name: traefik
hostname: traefik
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ${DOCKFIGS}/traefik/acme.json:/acme.json
- ${DOCKFIGS}/traefik/traefik.toml:/traefik.toml
labels:
traefik.enable: "true"
traefik.frontend.rule: "Host:monitor.local" #This is a local DNS entry the only way this monitoring page will work, remove this line in docker-compose.yml
traefik.port: "8080"
com.centurylinklabs.watchtower.enable: "true" #This is for watchtower.
homeassistant:
image: homeassistant/home-assistant
container_name: home-assistant
volumes:
- ${DOCKFIGS}/home-assistant:/config
- /etc/localtime:/etc/localtime:ro
devices:
- /dev/ttyACM0:/dev/ttyACM0
labels:
traefik.enable: "true"
traefik.frontend.rule: "Host:yourdomain.${DOMAIN}"
traefik.port: "8123"
com.centurylinklabs.watchtower.enable: "true"
ports:
- "8123:8123"
- "51826:51826"
restart: unless-stopped
@PostSven Thanks, this will definetly help me out with my configuration. I was trying to do the jwilder reverse proxy to host my nextcloud, ha, and plex containers. Seems like this would be a better solution to that. I also seen a vid on youtube about “exoframe” that rides on traefik to aide in making the configs and containers almost automatic.
EDIT: Video and in the desc. is the link to the procect Exofram Video
Hi,
I have my services running in multiple docker container, I am new to docker therefor i am using portainer, can someone help me setup traefik in a docker container using portainer instead of docker compose ?