Files
docker-compose-cookbooks/traefik/docker-compose.yml
T

46 lines
1.5 KiB
YAML

###############################################################################
# Traefik
#
# Should only need one instance of this.
# Make sure the .env file is updated
# docker-compose up -d
###############################################################################
version: '3.3'
networks:
web:
driver: bridge
services:
traefik:
# https://hub.docker.com/_/traefik
image: "traefik:${TRAEFIK_V}"
restart: unless-stopped
command:
- --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --api
- --providers.docker
ports:
- "80:80"
- "443:443"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
networks:
- web
labels:
# Dashboard
- "traefik.http.routers.traefik.rule=Host(`${TRAEFIK_DOMAIN_NAME}`)"
- "traefik.http.routers.traefik.service=api@internal"
- "traefik.http.routers.traefik.tls.certresolver=leresolver"
- "traefik.http.routers.traefik.entrypoints=websecure"
- "traefik.http.routers.traefik.middlewares=authtraefik"
- "traefik.http.middlewares.authtraefik.basicauth.users=<USER>:<PASSWORD>"
# global redirect to https
- "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)"
- "traefik.http.routers.http-catchall.entrypoints=web"
- "traefik.http.routers.http-catchall.middlewares=redirect-to-https"
# middleware redirect
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"