Files
ChatApp/infra/caddy/Caddyfile
T
byGalax 5bc30c950c feat(infra): migrate self-hosted backend to netralax.de
Move Supabase + LiveKit from the netralax.cloud VPS to a new netralax.de server. Adds the migration runbook (docs/), one-time move scripts (scripts/migrate/), and prod Caddy/LiveKit config templates (infra/). Repoints the desktop publish/changelog URLs and prod ops config to .de. JWT_SECRET + VAPID copied identically so already-installed clients keep working; the new server also serves the legacy .cloud hostnames.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-02 19:39:04 +02:00

92 lines
5.2 KiB
Caddyfile

# ─────────────────────────────────────────────────────────────────────────────
# Caddyfile — Produktion (NEW VPS, netralax.de)
#
# Dual-Domain-Übergang (.de + .cloud):
# Bereits installierte Desktop- (Vite) und Mobile- (Expo) Clients haben die
# ALTEN Hostnamen fest in ihre Bundles eingebacken
# (supabase.netralax.cloud, livekit.netralax.cloud, update.netralax.cloud).
# Deshalb bedient dieser NEUE Server BEIDE Domains aus denselben Backends:
# - die neuen *.netralax.de Hosts für aktuelle/neue Releases
# - die legacy *.netralax.cloud Hosts NUR damit Alt-Installationen weiter
# funktionieren, bis sie sich per Auto-Update auf .de umgestellt haben.
# Voraussetzung: die .cloud-DNS-A-Records müssen auf die NEUE VPS-IP zeigen.
# Die .cloud-Blöcke dürfen NICHT entfernt werden, solange noch Alt-Clients
# im Umlauf sind — sonst brechen alle bestehenden Installationen.
#
# TLS: Automatisches HTTPS via Let's Encrypt für alle Hosts.
# WebSockets: Caddy v2 reicht Upgrade/Connection-Header bei reverse_proxy
# transparent durch — sowohl für Supabase Realtime (/realtime/v1/websocket)
# als auch für LiveKit (/rtc). KEINE websocket-Direktive nötig/vorhanden.
#
# WICHTIG: Nur der Signaling-WS (7880) und das Supabase-Gateway (Kong 8000)
# laufen über Caddy. RTC-Medien (7881/tcp, 50000-50100/udp) und coturn
# (3478, 5349/TLS, 50200-50300/udp) gehen NICHT über Caddy und müssen direkt
# in der ufw geöffnet werden. TURNS auf 5349 braucht ein EIGENES Zertifikat
# für turn.netralax.de (siehe coturn.prod.conf.example).
# ─────────────────────────────────────────────────────────────────────────────
# ─────────────────────────────────────────────────────────────────────────────
# AKTIV ab Bootstrap: die NEUEN .de-Hosts.
# Die .cloud-Legacy-Blöcke stehen weiter unten und werden ERST beim Cutover
# (Runbook §10) einkommentiert — nämlich NACHDEM die .cloud-A-Records auf die
# neue VPS-IP zeigen. Grund: stehen die .cloud-Namen schon vorher in der aktiven
# Config, scheitert Caddy wiederholt an der Let's-Encrypt-Ausstellung (DNS zeigt
# noch auf den alten Server) und läuft ins ACME-Rate-Limit (5 Fehler/Host/Stunde).
# ─────────────────────────────────────────────────────────────────────────────
# Supabase API-Gateway (Kong multiplext auth/rest/realtime/storage/functions
# + Studio). EIN reverse_proxy genügt — KEINE Routen in Caddy aufsplitten.
supabase.netralax.de {
reverse_proxy localhost:8000
}
# LiveKit Signaling-WebSocket. Caddy übernimmt den WS-Upgrade automatisch.
# CORS-Header + OPTIONS-Preflight wie auf dem alten Server (Browser/Electron-
# Clients erwarten sie beim Token-/Connect-Handshake).
livekit.netralax.de {
header Access-Control-Allow-Origin "*"
header Access-Control-Allow-Methods "GET, POST, OPTIONS"
header Access-Control-Allow-Headers "Authorization, Content-Type"
header Access-Control-Expose-Headers "*"
@options method OPTIONS
handle @options {
respond 204
}
reverse_proxy localhost:7880
}
# electron-updater Artefakte (latest.yml + .exe + changelog.json).
# WICHTIG: docroot ist /var/www/updates (NICHT .../windows). release.mjs lädt
# nach /var/www/updates/windows/ hoch und die Clients holen unter dem URL-Pfad
# /windows/latest.yml — der Pfad-Präfix /windows/ muss also auf das Unterverzeichnis
# mappen. Mit root=/var/www/updates/windows entstünde .../windows/windows → 404.
update.netralax.de {
root * /var/www/updates
file_server
}
# ─────────────────────────────────────────────────────────────────────────────
# LEGACY .cloud-Hosts — AKTIV seit dem Cutover (DNS .cloud → neue VPS-IP).
# Liefern aus denselben Backends wie die .de-Hosts, damit bereits installierte
# Clients weiterlaufen, bis sie sich per Auto-Update auf .de umgestellt haben.
# NICHT entfernen, solange Alt-Clients im Umlauf sind.
# ─────────────────────────────────────────────────────────────────────────────
supabase.netralax.cloud {
reverse_proxy localhost:8000
}
livekit.netralax.cloud {
header Access-Control-Allow-Origin "*"
header Access-Control-Allow-Methods "GET, POST, OPTIONS"
header Access-Control-Allow-Headers "Authorization, Content-Type"
header Access-Control-Expose-Headers "*"
@options method OPTIONS
handle @options {
respond 204
}
reverse_proxy localhost:7880
}
update.netralax.cloud {
root * /var/www/updates
file_server
}