Traefik v2.3.2 Configuration
This is the docker compose and configuration for an instance of Traefik v2.3.2
You can find a quick draft for v1.7 configuration on an older commit
touch acme.json & chmod 600 acme.json
Let’s Encrypt is requiring an acme.json file to store certificates. Click here to know more
...
<service>:
...
labels:
- traefik.http.routers.<service>.rule=Host("<domain name>")
- traefik.http.services.<service>.loadbalancer.server.port=<port>
- traefik.http.routers.<service>.tls=true
- traefik.http.routers.<service>.tls.certresolver=letsencrypt
- traefik.http.routers.<service>.entrypoints=web-secure
- traefik.enable=true
...
Required labels:
Redirect incoming requests to <domain name>. Details on Traefik rules here
traefik.http.routers.<service>.rule=Host("<domain name>")
Enable tls on the service:
traefik.http.routers.<service>.tls=true
Use certresolver letsencrypt configured in traefik.toml:
traefik.http.routers.<service>.tls.certresolver=letsencrypt
Accept requests from web-secure entrypoint only:
traefik.http.routers.<service>.entrypoints=web-secure
More info here:
traefik.enable=true
Optional labels:
Redirect incoming traffic to port <port> of the service:
traefik.http.services.<service>.loadbalancer.server.port=<port>
Create an docker network with this command:
docker network create web
Add this at the end of your docker-compose file (you have to add it for every different docker-compose file)
...
networks:
web:
external: true
...
<service>:
...
networks:
web:
...
The network web enable traefik instance to communicate with other services from different docker-composes
docker-compose up