- Create Dockerfile for Nginx with envsubst for dynamic configuration. - Add djmaster.conf.template for Nginx configuration with upstream services. - Implement docker-entrypoint.sh to substitute environment variables in the Nginx config. - Add README.md in nginx-examples for guidance on using the Nginx template. - Include djmaster.conf.template in nginx-examples for local setup. - Introduce utility functions for fetching YouTube video snippets and titles.
119 lines
3.9 KiB
Caddyfile
119 lines
3.9 KiB
Caddyfile
{
|
|
# Deshabilitar HTTP/2 y HTTP/3 globalmente para soporte WebSocket
|
|
servers {
|
|
protocols h1 h2
|
|
}
|
|
}
|
|
|
|
djmaster.nextream.sytes.net
|
|
|
|
encode zstd gzip
|
|
|
|
# ── Facebook OAuth2 microserver (Node.js en puerto 3002) ──────────────────────
|
|
handle /fb-server/* {
|
|
uri strip_prefix /fb-server
|
|
reverse_proxy restreamer-ui:3002
|
|
}
|
|
|
|
# ── LiveKit token endpoint (Node.js en puerto 3002) ───────────────────────────
|
|
# POST /livekit/token → genera AccessToken JWT firmado
|
|
# GET /livekit/config → devuelve wsUrl público (sin secretos)
|
|
handle /livekit/* {
|
|
reverse_proxy restreamer-ui:3002
|
|
}
|
|
|
|
# ── WebRTC relay WebSocket + status (Node.js en puerto 3002) ─────────────────
|
|
# 127.0.0.1 evita problema de resolución IPv6 en Alpine ("localhost" → ::1)
|
|
# HTTP/1.1 necesario para WebSocket upgrade (Caddy requiere versión explícita)
|
|
handle /webrtc-relay/* {
|
|
reverse_proxy restreamer-ui:3002 {
|
|
transport http {
|
|
versions 1.1
|
|
}
|
|
}
|
|
}
|
|
|
|
# ── WebRTC Room HTML (sala para el presentador) ───────────────────────────────
|
|
# Sirve la página estática sin fallback al index.html de la SPA
|
|
handle /webrtc-room/* {
|
|
reverse_proxy restreamer-ui:3000
|
|
}
|
|
handle /webrtc-room {
|
|
redir /webrtc-room/ 302
|
|
}
|
|
|
|
# ── yt-dlp stream extractor (servicio externo configurable via env) ───────────
|
|
# /yt-stream/{VIDEO_ID} → http://YTDLP_HOST/stream/{VIDEO_ID}
|
|
# yt-dlp puede tardar 20-30s — timeouts extendidos a 120s
|
|
handle_path /yt-stream/* {
|
|
rewrite * /stream{path}
|
|
reverse_proxy {env.YTDLP_HOST} {
|
|
transport http {
|
|
dial_timeout 10s
|
|
response_header_timeout 120s
|
|
read_timeout 120s
|
|
}
|
|
}
|
|
}
|
|
|
|
# ── yt-dlp titles proxy (map /yt-titles/{id} → internal /stream/{id}) ───────
|
|
# Some deployments expose metadata at /stream; proxy to the internal titles service.
|
|
handle_path /yt-titles/* {
|
|
rewrite * /stream{path}
|
|
reverse_proxy {env.YTDLP_TITLES_HOST} {
|
|
transport http {
|
|
versions 1.1
|
|
dial_timeout 10s
|
|
response_header_timeout 15s
|
|
read_timeout 15s
|
|
}
|
|
}
|
|
}
|
|
|
|
# OAuth2 callback page — must be served as a static HTML (not the SPA index)
|
|
handle /oauth2callback {
|
|
rewrite * /oauth2callback.html
|
|
reverse_proxy restreamer-ui:3000
|
|
}
|
|
|
|
# Facebook OAuth2 callback popup — soporta tanto .html como .htm
|
|
handle /oauth/facebook/callback.html {
|
|
reverse_proxy restreamer-ui:3000
|
|
}
|
|
|
|
handle /oauth/facebook/callback.htm {
|
|
rewrite * /oauth/facebook/callback.html
|
|
reverse_proxy restreamer-ui:3000
|
|
}
|
|
|
|
handle /oauth/facebook/callback {
|
|
redir /oauth/facebook/callback.html{query} 302
|
|
}
|
|
|
|
# ── LiveKit Ingress WHIP proxy: OBS publica vía WHIP al mismo dominio ─────────
|
|
# OBS usa: https://djmaster.nextream.sytes.net/w/<streamKey>
|
|
# Caddy lo reenvía al servicio livekit-ingress interno (solo accesible localmente).
|
|
# LIVEKIT_INGRESS_HOST se configura en docker-compose (p.ej. 192.168.1.20:8088).
|
|
handle /w/* {
|
|
reverse_proxy {env.LIVEKIT_INGRESS_HOST} {
|
|
header_up Host {upstream_hostport}
|
|
}
|
|
}
|
|
|
|
# ── WHIP info API: genera sesión Ingress (Node en :3002) ─────────────────────
|
|
handle /api/whip/* {
|
|
reverse_proxy restreamer-ui:3002
|
|
}
|
|
|
|
# ── WHEP relay proxy: Core hace pull aquí → egress server ───────────────────
|
|
# Core input: https://djmaster.nextream.sytes.net/whep/rooms/<channelId>
|
|
# EGRESS_HOST se configura en docker-compose (URL del servidor egress).
|
|
handle /whep/* {
|
|
reverse_proxy {env.EGRESS_HOST}
|
|
}
|
|
|
|
# SPA — proxy al servidor interno de la aplicación (serve -s build)
|
|
handle {
|
|
reverse_proxy restreamer-ui:3000
|
|
}
|