Skip to content

Instantly share code, notes, and snippets.

@Kolahzary
Last active August 17, 2018 23:05
Show Gist options
  • Save Kolahzary/1d388240e319e670ad80b9d2a2105959 to your computer and use it in GitHub Desktop.
Save Kolahzary/1d388240e319e670ad80b9d2a2105959 to your computer and use it in GitHub Desktop.
Example docker stack.yml for Traefik with ACME https, frontend Basic Auth and PathPrefix with priority
docker network create -d overlay traefik-overlay
version: '3.4'
services:
traefik:
image: traefik:1.7-alpine
command:
- "--api"
- "--api.statistics"
- "--api.entryPoint=traefik"
- "--ping"
- "--ping.entryPoint=ping"
- "--entrypoints=Name:http Address::80 Redirect.EntryPoint:https"
- "--entrypoints=Name:https Address::443 TLS"
- "--entrypoints=Name:traefik Address::8080"
- "--entrypoints=Name:ping Address::8082"
- "--defaultentrypoints=http,https"
#- "--acme"
#- "--acme.storage=/etc/traefik/acme/acme.json"
#- "--acme.entryPoint=https"
#- "--acme.httpChallenge.entryPoint=http"
#- "--acme.onHostRule=true"
#- "--acme.onDemand=false"
#- "[email protected]"
- "--docker"
- "--docker.swarmMode"
- "--docker.domain=traefik.local"
- "--docker.watch"
deploy:
mode: global
placement:
constraints:
- node.role == manager
update_config:
parallelism: 1
delay: 10s
resources:
limits:
cpus: '0.50'
memory: 50M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
window: 120s
labels:
- "traefik.enabled=true"
- "traefik.docker.network=traefik"
#- "traefik.protocol=http"
- "traefik.weight=10"
- "traefik.dashboard.port=8080"
- "traefik.dashboard.backend=dashboard"
- "traefik.dashboard.frontend.rule=Host:traefik.local"
- "traefik.dashboard.frontend.auth.basic=admin:$$apr1$$Oth0NfK7$$/xBPWIYJMnBS8W8Vvc07m0" # admin:admin basic auth generated by htpasswd
- "traefik.dashboard.frontend.priority: 10"
- "traefik.ping.port=8082"
- "traefik.ping.backend=ping"
- "traefik.ping.frontend.rule=Host:traefik.local; PathPrefix:/ping"
- "traefik.ping.frontend.priority: 20"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
#- ./acme.json:/etc/traefik/acme/acme.json
networks:
- traefik
ports:
- target: 80
published: 80
protocol: tcp
mode: host
#mode: ingress
- target: 443
published: 443
protocol: tcp
mode: host
#mode: ingress
#configs:
# - source: traefik.toml
# target: /etc/traefik/traefik.toml
networks:
traefik:
external:
name: traefik-overlay
#configs:
# traefik.toml:
# file: ./traefik.toml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment