version: "3.9"
services:
  media:
    image: nginx:1.27-alpine
    restart: unless-stopped

    volumes:
      - ./nginx/html:/usr/share/nginx/html:ro
      - ./nginx/conf.d:/etc/nginx/conf.d:ro

    labels:
      # ——— Traefik v2 path-based routing ———
      - traefik.enable=true

      # Route: https://b.mindboost.team/media  (optionally with /anything/after/that)
      - traefik.http.routers.media.rule=Host(`b.mindboost.team`) && PathPrefix(`/media`)

      # Strip /media from the request *before* it reaches Nginx,
      # so Nginx still serves /index.html, /css/site.css, etc.
      - traefik.http.routers.media.middlewares=media-strip
      - traefik.http.middlewares.media-strip.stripPrefix.prefixes=/media

      # TLS via the proxys “websecure” entrypoint
      - traefik.http.routers.media.entrypoints=websecure
      - traefik.http.routers.media.tls.certresolver=letsencrypt

      # Upstream container port
      - traefik.http.services.media.loadbalancer.server.port=80

    networks:
      - proxy
networks:
  proxy:
    external: true