Files
docker-compose-cookbooks/traefik/docker-compose.yml
T
2020-04-25 15:52:39 -07:00

59 lines
2.0 KiB
YAML

###############################################################################
# Traefik
#
# Should only need one instance of this.
# Make sure the .env file is updated
# docker-compose up -d
###############################################################################
version: '2'
networks:
web:
driver: bridge
volumes:
traefik:
services:
traefik:
# https://hub.docker.com/_/traefik
image: "traefik:${TRAEFIK_V}"
restart: unless-stopped
command:
- --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --api
- "--log.level=DEBUG"
- "--api.dashboard=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--certificatesresolvers.letsencrypt.acme.httpchallenge=true"
- "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web"
- "--certificatesresolvers.letsencrypt.acme.email=${TRAEFIK_LE_EMAIL}"
- "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
ports:
- "80:80"
- "443:443"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- traefik:/letsencrypt
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=letsencrypt"
- "traefik.http.routers.traefik.entrypoints=websecure"
- "traefik.http.routers.traefik.middlewares=dashboardauth"
- "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@docker"
# middleware redirect
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
- "traefik.enable=true"