Traefik

Version 1.2 by chrisby on 2023/11/18 15:01

Traefik is usually included in the other Software Stacks, but this page is for special use cases.

Redirect from HTTP to HTTPS
traefik:
   image: "traefik:latest"
   container_name: "traefik"
   restart: unless-stopped
   command:
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.myresolver.acme.tlschallenge=true"
      - "--certificatesresolvers.myresolver.acme.email=<EMAIL>"
      - "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
     # This enables redirect from HTTP to HTTPS
      - "--entrypoints.web.address=:80"
      - "--entrypoints.web.http.redirections.entryPoint.to=websecure"
      - "--entrypoints.web.http.redirections.entryPoint.scheme=https"
      - "--entrypoints.web.http.redirections.entryPoint.permanent=true"
     # Uncomment for test mode. This allows detailed logging and creation of a fake certificate.
     # - "--log.level=DEBUG"
     # - "--certificatesresolvers.myresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory"
   ports:
      - "80:80"
      - "443:443"
   volumes:
      - "./data/traefik/letsencrypt:/letsencrypt"
      - "/var/run/docker.sock:/var/run/docker.sock:ro"