Skip to content

Instantly share code, notes, and snippets.

@wongyouth
Last active June 24, 2019 03:25
Show Gist options
  • Save wongyouth/d54aeffad8ad1ad7e77e21ce48e16623 to your computer and use it in GitHub Desktop.
Save wongyouth/d54aeffad8ad1ad7e77e21ce48e16623 to your computer and use it in GitHub Desktop.
Docker Swarm mode with reverse proxy traefik config example
version: '3.3'
services:
reverse-proxy:
image: traefik:v1.7
ports:
- target: 80
published: 80
mode: host
- target: 8080
published: 8080
mode: host
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- acme:/etc/acme/
deploy:
placement:
constraints: [node.role==manager]
restart_policy:
condition: on-failure
resources:
limits:
cpus: '0.20'
memory: 20M
command:
- --api
- --accessLog
- --docker
- --docker.swarmmode
- --docker.exposedbydefault=false
- --api.entrypoint=api
- --entrypoints=Name:api Address::8080 Auth.Basic.Users=user:$$1$$3uST9Qvw$$pptDCnUTW8Ays7ARJ4ifJ.
- --entrypoints=Name:http Address::80
# - --acme
# - --acme.email=${ACME_EMAIL?Variable AMCE_EMAIL not set}
# - --acme.storage=/etc/acme/acme.json
# - --acme.entryPoint=https
# - --acme.dnsChallenge.provider=alidns
# - --acme.acmelogging=true
# - --acme.domains.main="*.${ACME_DOMAIN?Varialbe ACME_DOMAIN not set}"
# - --acme.domains.sans=${ACME_DOMAIN
# environments:
# - ALICLOUD_ACCESS_KEY=${ALICLOUD_ACCESS_KEY?Variable ALICLOUD_ACCESS_KEY not set}
# - ALICLOUD_SECRET_KEY=${ALICLOUD_SECRET_KEY?Variable ALICLOUD_SECRET_KEY not set}
# - ALICLOUD_REGION_ID=${ALICLOUD_REGION_ID?Variable ALICLOUD_REGION_ID not set}
whoami1:
image: containous/whoami
deploy:
labels:
- traefik.frontend.rule=Host:whoami.docker.localhost
- traefik.enable=true
- traefik.port=80
whoami2:
image: containous/whoami
deploy:
labels:
- traefik.frontend.rule=PathPrefixStrip:/api/bile-server/
- traefik.enable=true
- traefik.port=80
- traefik.frontend.auth.basic=user:$$1$$3uST9Qvw$$pptDCnUTW8Ays7ARJ4ifJ.
whoami3:
image: containous/whoami
deploy:
labels:
- traefik.frontend.rule=PathPrefix:/
- traefik.enable=true
- traefik.port=80
volumes:
acme:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment