Traefik
Makefile
update:
docker-compose up -d
create:
docker network create traefik_network
build: create update
.env
TRAEFIK_USER=admin
#TRAEFIK_PASSWORD=admin | htpasswd -nb admin admin
TRAEFIK_PASSWORD=$$apr1$$WylKbdGp$$8TvRP0N6PDO4auqR1DkcG.
TRAEFIK_URL_TRAEFIK=traefik.clients.xelyos.fr
DOCKER_TRAEFIK_NETWORK=traefik_network
DOCKER_CONTAINER_TRAEFIK=traefik_network
docker-compose.yaml
networks:
traefik_network:
name: ${DOCKER_TRAEFIK_NETWORK}
external: true
services:
traefik:
restart: unless-stopped
image: traefik:v3.2
container_name: ${DOCKER_CONTAINER_TRAEFIK}
command:
- "--log.level=DEBUG"
- "--api.insecure=false"
# Activer le tableau de bord
- "--api.dashboard=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.httpClientTimeout=300"
# Entrées HTTP et HTTPS
- "--entrypoints.web.address=:80"
- "--entryPoints.websecure.address=:443"
# Redirection HTTP vers HTTPS
- "--entrypoints.web.http.redirections.entryPoint.to=websecure"
- "--entrypoints.web.http.redirections.entryPoint.scheme=https"
# Certificats Let's Encrypt
- "--certificatesresolvers.myresolver.acme.tlschallenge=true"
- "--certificatesresolvers.myresolver.acme.email=aros@xelyos.fr"
- "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
ports:
- "80:80" # HTTP
- "443:443" # HTTPS
- "8080:8080" # Tableau de bord
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./letsencrypt:/letsencrypt
networks:
- traefik_network
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.rule=Host(`${TRAEFIK_URL_TRAEFIK}`)"
- "traefik.http.routers.traefik.tls.certresolver=myresolver"
- "traefik.http.routers.traefik.service=api@internal"
- "traefik.http.routers.traefik.middlewares=auth"
- "traefik.http.middlewares.auth.basicauth.users=admin:$$apr1$$WylKbdGp$$8TvRP0N6PDO4auqR1DkcG."