Last active
October 29, 2023 13:07
-
-
Save MerNat/8ee69c5eeaa4ac909b0044f48e9569b0 to your computer and use it in GitHub Desktop.
Traefik docker compose yml for cluster or swarm configuration.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.4' | |
services: | |
consul-leader: | |
image: consul | |
command: agent -server -client=0.0.0.0 -bootstrap -ui | |
volumes: | |
- consul-data-leader:/consul/data | |
environment: | |
- CONSUL_BIND_INTERFACE=eth0 | |
- 'CONSUL_LOCAL_CONFIG={"leave_on_terminate": true}' | |
networks: | |
- default | |
- webgateway | |
deploy: | |
labels: | |
- traefik.frontend.rule=Host:consul.example.com | |
- traefik.enable=true | |
- traefik.port=8500 | |
- traefik.tags=consulTag | |
- traefik.docker.network=webgateway | |
- traefik.redirectorservice.frontend.entryPoints=http | |
- traefik.redirectorservice.frontend.redirect.entryPoint=https | |
- traefik.webservice.frontend.entryPoints=https | |
consul-replica: | |
image: consul | |
command: agent -server -client=0.0.0.0 -retry-join="consul-leader" | |
volumes: | |
- consul-data-replica:/consul/data | |
environment: | |
- CONSUL_BIND_INTERFACE=eth0 | |
- 'CONSUL_LOCAL_CONFIG={"leave_on_terminate": true}' | |
networks: | |
- default | |
- webgateway | |
deploy: | |
replicas: 1 | |
placement: | |
preferences: | |
- spread: node.id | |
traefik: | |
image: traefik:alpine | |
ports: | |
- 80:80 | |
- 443:443 | |
- 8080:8080 | |
deploy: | |
replicas: 1 | |
placement: | |
constraints: | |
- node.role == manager | |
preferences: | |
- spread: node.id | |
labels: | |
- traefik.frontend.rule=Host:example.com | |
- traefik.enable=true | |
- traefik.port=8080 | |
- traefik.tags=webgateway | |
- traefik.docker.network=webgateway | |
- traefik.redirectorservice.frontend.entryPoints=http | |
- traefik.redirectorservice.frontend.redirect.entryPoint=https | |
- traefik.webservice.frontend.entryPoints=https | |
# - traefik.frontend.auth.basic.users=${USERNAME}:${HASHED_PASSWORD} | |
volumes: | |
- /var/run/docker.sock:/var/run/docker.sock | |
command: > | |
--docker | |
--docker.domain=example.com | |
--docker.swarmmode | |
--docker.watch | |
--docker.exposedbydefault=false | |
--constraints=tag==webgateway | |
--entrypoints='Name:http Address::80' | |
--entrypoints='Name:https Address::443 TLS' | |
--consul | |
--consul.endpoint="consul-leader:8500" | |
--acme | |
--acme.email=support@example.com | |
--acme.storage="traefik/acme/account" | |
--acme.entryPoint=https | |
--acme.httpChallenge.entryPoint=http | |
--acme.onhostrule=true | |
--acme.acmelogging=true | |
--logLevel=INFO | |
--accessLog | |
--web | |
networks: | |
- default | |
- webgateway | |
depends_on: | |
- consul-leader | |
blog: | |
image: httpd:alpine | |
deploy: | |
replicas: 1 | |
labels: | |
- traefik.frontend.rule=Host:test.example.com | |
- traefik.enable=true | |
- traefik.port=80 | |
- traefik.tags=webgateway | |
- traefik.docker.network=webgateway | |
- traefik.redirectorservice.frontend.entryPoints=http | |
- traefik.redirectorservice.frontend.redirect.entryPoint=https | |
- traefik.webservice.frontend.entryPoints=https | |
networks: | |
- default | |
- webgateway | |
volumes: | |
consul-data-leader: | |
name: consul-data-leader | |
consul-data-replica: | |
name: consul-data-replica | |
networks: | |
webgateway: | |
external: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment