version: "3.9" services: traefik: image: traefik command: - --api=true - --api.insecure=true - --pilot.token=$TRAEFIK_PILOT_TOKEN - --experimental.plugins.traefik-ondemand-plugin.moduleName=github.com/acouvreur/traefik-ondemand-plugin - --experimental.plugins.traefik-ondemand-plugin.version=v1.2.0 - --providers.docker=true - --providers.docker.swarmmode=true - --providers.file.filename=/etc/traefik/dynamic-config.yml - --entrypoints.http.address=:80 - --entrypoints.https.address=:443 ports: - "80:80" - "443:443" - "8080:8080" volumes: - '/var/run/docker.sock:/var/run/docker.sock' ondemand: image: ghcr.io/acouvreur/traefik-ondemand-service:1 command: - --swarmMode=true volumes: - '/var/run/docker.sock:/var/run/docker.sock' deploy: labels: - traefik.enable=true - traefik.http.middlewares.ondemand.plugin.traefik-ondemand-plugin.name=DOCKER_SWARM_nginx - traefik.http.middlewares.ondemand.plugin.traefik-ondemand-plugin.serviceUrl=http://ondemand:10000 - traefik.http.middlewares.ondemand.plugin.traefik-ondemand-plugin.timeout=1m - traefik.http.services.ondemand.loadbalancer.server.port=10000 nginx: image: nginx deploy: replicas: 0 labels: - traefik.enable=true # If you do not use the swarm load balancer, traefik will evict the service from its pool # as soon as the service is 0/0. If you do not set that, fallback to dynamic-config.yml file usage. - traefik.docker.lbswarm=true - traefik.http.routers.nginx.middlewares=ondemand@docker - traefik.http.routers.nginx.rule=PathPrefix(`/nginx`) - traefik.http.services.nginx.loadbalancer.server.port=80