ron's blog


My Traefik config with Docker Compose

Update: I am not using this config on production, but it's a start for yours if you want to.

Traefik is a modern HTTP reverse proxy and load balancer that makes deploying microservices easy. Traefik integrates with your existing infrastructure components (Docker, Swarm mode, Kubernetes, Marathon, Consul, Etcd, Rancher, Amazon ECS, ...) and configures itself automatically and dynamically. Pointing Traefik at your orchestrator should be the only configuration step you need.

My config is bassicly just a bunch of bits and pieces from the docs combined into a nice working one

traefik.toml

logLevel = "INFO"
defaultEntryPoints = ["https","http"]

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

[acme]
email = "YOUR EMAIL HERE ! ! ! ! ! !"
storage = "acme.json"
onHostRule = true
caServer = "https://acme-v02.api.letsencrypt.org/directory"
entryPoint = "https"
  [acme.httpChallenge]
  entryPoint = "http"

docker-compose.yaml

version: '3'

services:
    reverse-proxy:
        image: traefik # The official Traefik docker image
        command: --api --docker # Enables the web UI and tells Traefik to listen to docker
        ports:
            - "80:80"     # The HTTP port
            - "443:443"
            - "8080:8080" # The Web UI (enabled by --api)
        volumes:
            - /CHANGEMETOYOURPATHCANTUSERELATIVEPATHHERE/acme.json:/acme.json
            - ./trafeik.toml:/etc/traefik/traefik.toml
            - /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
    whoami:
        image: containous/whoami # A container that exposes an API to show its IP address
        labels:
            - "traefik.frontend.rule=Host:CHANGEME.example.com"

Have fun.


Contact methods may be found on my main site

Find a mistake? Send the fix or raise an issue with GitHub

© 2019 Ron B