version: "3.3"
services:
traefik:
image: "traefik:v2.2"
deploy:
labels:
- traefik.enable=true
-
traefik.docker.network=traefik-public
# ROUTER HTTP
- traefik.http.routers.traefik-http.entrypoints=web
- traefik.http.routers.traefik-http.rule=Host(
traefik.volkov.club
)
# ROUTER HTTPS
- traefik.http.routers.traefik-https.entrypoints=websecure
- traefik.http.routers.traefik-https.rule=Host(
traefik.volkov.club
)
- traefik.http.services.traefik.loadbalancer.server.port=8080
command:
- "--log.level=DEBUG"
- "--api.insecure=true"
# Enable the access log, with HTTP requests
- --accesslog
# Enable the Traefik log, for configurations and errors
- --log
# Activates the Swarm Mode (instead of standalone Docker).
- "--providers.docker.swarmMode=true"
# Expose containers by default through Traefik. If set to false, containers that don't
# have a traefik.enable=true label will be ignored from the resulting routing configuration.
- "--providers.docker.exposedbydefault=false"
# ENTRY POINTS
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
ports:
- "80:80"
- "8080:8080"
- "443:443"
volumes:
# Add Docker as a mounted volume, so that Traefik can read the labels of other services
- /var/run/docker.sock:/var/run/docker.sock:ro
# Mount the volume to store the certificates
- traefik-public-certificates:/opt/traefik/
networks:
- "traefik-public"
volumes:
# Create a volume to store the certificates, there is a constraint to make sure
# Traefik is always deployed to the same Docker node with the same volume containing
# the HTTPS certificates
traefik-public-certificates:
networks:
traefik-public:
external: true