traefik/docker-compose.yml
2023-11-24 17:46:05 +01:00

34 lines
1.2 KiB
YAML

version: "1.0"
networks:
default:
name: "${TRAEFIK_NETWORK}"
external: true
services:
traefik:
image: "traefik:latest"
container_name: "${PROJECT_NAME}_traefik"
hostname: "${PROJECT_NAME}"
network_mode: "host"
restart: "unless-stopped"
volumes:
- "./traefik.yml:/traefik.yml:ro"
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./tls.yml:/etc/traefik/dynamic_conf/conf.yml:ro"
- "./tls-data:/tls:ro"
labels:
- "traefik.enable=true"
- "traefik.docker.network=${TRAEFIK_NETWORK}"
# HTTP -> HTTPS
- "traefik.http.routers.http-catchall.entrypoints=web"
- "traefik.http.routers.http-catchall.rule=HostRegexp(`{host:.+}`)"
- "traefik.http.routers.http-catchall.middlewares=redirect-to-https"
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
# HTTPS Routers
- "traefik.http.routers.${PROJECT_NAME}_traefik.rule=Host(`${PROJECT_URL}`)"
- "traefik.http.services.${PROJECT_NAME}_traefik.loadbalancer.server.port=8080"
- "traefik.http.routers.${PROJECT_NAME}_traefik.tls=true"
- "traefik.http.routers.${PROJECT_NAME}_traefik.entrypoints=websecure"