
services:
  traefik:
    # image: "traefik:v2.4"
    # image: "traefik:v3.1"
    image: "traefik:v3.6.2"
    container_name: "traefik"
    hostname: "traefik"
    networks:
      - traefik
    env_file:
      - .env
    ports:
      - "80:80"
      - "443:443"
      # - "8080:8080"

    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
      - "./traefik.yml:/traefik.yml:ro"
      - /var/log/traefik/:/opt/traefik/logs
      - /srv/traefik/letsencrypt:/etc/letsencrypt
    # command: 
      # - --api.insecure=false 
      # - --api.insecure=true 
    restart: unless-stopped
    labels:
        # - "traefik.enable=true"
        # - "traefik.port=8080"
        # - "traefik.http.routers.traefiks.entrypoints=websecure"
        # - "traefik.http.routers.traefiks.rule=Host(`monitor.$DOMAIN_NAME`)"
        # - "traefik.http.routers.traefiks.tls.certresolver=letsencr"
        # - "traefik.http.middlewares.auth.basicauth.users=admin:$$2a$12$2fgQL6tIUB7qwKVQPrhUQew3wZ3noWmLt5dmyk.KWDcuZR5vs01wO"
        # - "traefik.http.routers.traefiks.middlewares=auth"
        - traefik.http.middlewares.https_redirect.redirectscheme.scheme=https
        - traefik.http.middlewares.https_redirect.redirectscheme.permanent=true
        - traefik.http.routers.http_catchall.rule=HostRegexp(`{any:.+}`)
        - traefik.http.routers.http_catchall.entrypoints=web
        - traefik.http.routers.http_catchall.middlewares=https_redirect

networks:
  traefik:
    external: true
