From 1a530379681ee831c8eefd977e9392f2f263a7d6 Mon Sep 17 00:00:00 2001 From: Robert Rapp Date: Wed, 16 Jul 2025 18:01:56 +0200 Subject: [PATCH] initial commit with docker-compose file and default configs --- README.md | 16 ++++++++++++++++ docker-compose.yml | 31 +++++++++++++++++++++++++++++++ nginx/conf.d/default.conf | 25 +++++++++++++++++++++++++ nginx/html/index.html | 15 +++++++++++++++ 4 files changed, 87 insertions(+) create mode 100644 README.md create mode 100644 docker-compose.yml create mode 100644 nginx/conf.d/default.conf create mode 100644 nginx/html/index.html diff --git a/README.md b/README.md new file mode 100644 index 0000000..21680b6 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# 🎧 Mindboost Media Streaming Server (NGINX + Byte-Range) + +Diese Anleitung beschreibt die Einrichtung eines NGINX-Servers zur effizienten Bereitstellung von Audioinhalten (MP3, OPUS), wie sie von der Mindboost-Plattform verwendet werden. +Die Konfiguration unterstützt **HTTP-Streaming über Byte-Range Requests**, was schnelle Ladezeiten und PWA-Kompatibilität sicherstellt. + +--- + +## 1 · What you get + +| Feature | Notes | +| ------------------------------- | -------------------------------------------------------------------- | +| 🔗 **Single-domain routing** | `https://b.mindboost.team/media/**` (no extra sub-domain quota). | +| 🚀 **Out-of-the-box streaming** | Correct `Content-Type` for `.opus`, `.ogg`, `.mp3`, `.flac`, `.wav`. | +| 🗄️ **Long-term browser cache** | `Cache-Control: public, max-age=2592000` (≈ 30 days) for audio. | +| 🔒 **HTTPS via Let’s Encrypt** | Handled by Traefik (`websecure` entrypoint). | +| 🐳 **One-command deployment** | `docker compose up -d`—and done. | diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..caaf5da --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,31 @@ +services: + media: + image: nginx:1.27-alpine + container_name: mindboost_media_nginx + 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 proxy’s “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 diff --git a/nginx/conf.d/default.conf b/nginx/conf.d/default.conf new file mode 100644 index 0000000..4bb9a97 --- /dev/null +++ b/nginx/conf.d/default.conf @@ -0,0 +1,25 @@ +server { + listen 80; + server_name localhost; + + root /usr/share/nginx/html; + index index.html; + + # --- STATIC WEB UI ------------------------------------------------------- + location / { + try_files $uri $uri/ =404; + } + + # --- MEDIA FILES --------------------------------------------------------- + # Anything with audio-ish extension gets correct MIME + long-term caching. + location ~ \.(opus|ogg|mp3|flac|wav)$ { + # 30-day client cache, tweak at will + add_header Cache-Control "public, max-age=2592000" always; + + # nginx:1.27 doesn’t know .opus by default → teach it: + types { audio/opus opus; } + + try_files $uri =404; + } + } +} diff --git a/nginx/html/index.html b/nginx/html/index.html new file mode 100644 index 0000000..a62b1ab --- /dev/null +++ b/nginx/html/index.html @@ -0,0 +1,15 @@ + + + + + Hello from b.mindboost.team 🎉 + + +

🚀 Nginx inside Docker – it works!

+

+ Edit + nginx/html/index.html + and re-deploy to see changes. +

+ +