Skip to content

Instantly share code, notes, and snippets.

@mseptiaan
Last active March 8, 2020 21:55
Show Gist options
  • Save mseptiaan/5fb926a9940f103398d6a38a5c5c6eb5 to your computer and use it in GitHub Desktop.
Save mseptiaan/5fb926a9940f103398d6a38a5c5c6eb5 to your computer and use it in GitHub Desktop.
konfigurasi docker-compose.yaml
version: "3.3"
services:
traefik:
image: traefik:v2.1
command:
- --entryPoints.http.address=:80
- --entryPoints.https.address=:443
- --api=true
- --log.level=ERROR
- --log.filePath=/configuration/traefik.log
- --log.format=json
- --accesslog=true
- --accesslog.filepath=/configuration/access.log
- --accesslog.filters.statuscodes=300-599
- --accesslog.filters.retryattempts
- --accesslog.filters.minduration=10ms
- --tracing=true
- --tracing.serviceName=traefik
- --tracing.spanNameLimit=150
- --accesslog.bufferingsize=100
- --providers.docker=true
- --providers.docker.endpoint=unix:///var/run/docker.sock
- --providers.docker.swarmMode=true
- --providers.docker.swarmModeRefreshSeconds=30s
- --providers.docker.defaultrule=Host(`local.test`)
- --providers.docker.exposedByDefault=false
- --providers.docker.network=traefik_docker-net
- --providers.file.directory=/configuration/
- --providers.file.watch=true
networks:
- docker-net
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./configuration/:/configuration/
- ./certs:/certs/
deploy:
placement:
constraints:
- node.role == manager
labels:
- "traefik.enable=true"
# Dashboard
- "traefik.http.routers.traefik.rule=Host(`traefik.local.test`)"
- "traefik.http.routers.traefik.service=api@internal"
- "traefik.http.routers.traefik.tls=true"
- "traefik.http.routers.traefik.entrypoints=https"
- "traefik.http.routers.traefik.middlewares=auth-traefik"
# Swarm Mode
- "traefik.http.services.traefik.loadbalancer.server.port=80"
# Basic Auth
- "traefik.http.middlewares.auth-traefik.basicauth.users=user:$$2y$$10$$4KmJDC4z.....90c3fm8L1p5ZdS"
# Global http to https redirect
- "traefik.http.routers.http-catchall.rule=HostRegexp(`{host:.+}`)"
- "traefik.http.routers.http-catchall.entrypoints=http"
- "traefik.http.routers.http-catchall.middlewares=redirect-to-https"
# Middleware redirect
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
portainer:
image: portainer/portainer
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "portainerdata:/data"
networks:
- docker-net
deploy:
placement:
constraints:
- node.role == manager
labels:
- "traefik.enable=true"
- "traefik.http.routers.portainer.entrypoints=https"
- "traefik.http.routers.portainer.rule=Host(`portainer.local.test`)"
- "traefik.http.routers.portainer.tls=true"
- "traefik.http.routers.portainer.service=portainer-lb"
- "traefik.http.routers.portainer.middlewares=traefik-compress"
- "traefik.http.services.portainer-lb.loadbalancer.server.port=9000"
# Compress
- "traefik.http.middlewares.traefik-compress.compress=true"
web:
image: emilevauge/whoami
networks:
- docker-net
deploy:
replicas: 3
placement:
constraints:
- node.role == manager
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik_docker-net"
- "traefik.http.routers.whoami.entrypoints=https"
- "traefik.http.routers.whoami.rule=Host(`whoami.local.test`)"
- "traefik.http.routers.whoami.tls=true"
- "traefik.http.routers.whoami.service=whoami-lb"
- "traefik.http.routers.whoami.middlewares=traefik-compress"
- "traefik.http.services.whoami-lb.loadbalancer.server.port=80"
networks:
docker-net:
driver: overlay
volumes:
portainerdata:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment