Traefik through Docker
·1 min
Traefik through Docker Compose seems to be a much cleaner way than manually installing and configuring Nginx, like I used to do earlier.
traefik.yaml:
entryPoints:
web:
address: ":80"
http:
redirections:
entryPoint:
to: websecure
websecure:
address: ":443"
providers:
docker: {}
certificatesResolvers:
myresolver:
acme:
email: you@example.com
storage: /data/letsencrypt.json
httpChallenge:
entryPoint: web
And docker-compose should contain something like the following:
services:
traefik:
image: traefik:v2.5 # TODO: try with "latest" instead of "2.5".
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- "./traefik.yaml:/etc/traefik/traefik.yaml"
- "./traefik/data:/data"
- "/var/run/docker.sock:/var/run/docker.sock"
some-web-service-that-needs-a-reverse-proxy:
# ...
labels:
- "traefik.http.routers.photoprism.rule=Host(`example.com`)"
- "traefik.http.routers.photoprism.tls=true"
- "traefik.http.routers.photoprism.tls.certresolver=myresolver"