Box-Konsole hinter MC2-Reverse-Proxy (kein Firewall-Port noetig)

Problem: ttyd auf :7682 war von aussen per ufw geblockt (nur 7681/9001 offen), also
im Browser Timeout — und ufw oeffnen braucht sudo, das MC2 hier nicht passwortlos hat.

Fix: ttyd bindet jetzt NUR an Loopback (--interface lo, --base-path /console) und wird
von MC2 ueber den ohnehin offenen Port 9001 same-origin durchgereicht:
- routers/console.py: HTTP-Passthrough (index/token) + WebSocket-Bridge (tty-Subprotokoll
  auf beiden Seiten) → /console/ + /console/ws.
- app.py: console.router VOR dem SPA-Catch-all eingehaengt.
- config: BOX_CONSOLE_UPSTREAM (127.0.0.1:7682) + BOX_CONSOLE_PATH (/console/);
  agent_status liefert box_console_url=/console/ + reachable=Upstream-Check.
- deploy/box-console.service: --interface lo --base-path /console.
- vite: /console (ws:true) fuer die Dev-Vorschau geproxyt.

Kein Firewall-/sudo-Eingriff noetig; Konsole laeuft same-origin zum Dashboard.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hitonabi
2026-07-04 20:58:40 +02:00
parent 18afa37412
commit 00fc7d6d81
6 changed files with 110 additions and 14 deletions
+8 -4
View File
@@ -97,10 +97,14 @@ VOICE_SERVICE_URL = os.environ.get("MC_VOICE_SERVICE_URL", "http://127.0.0.1:865
# Hermes-Terminal: ttyd-Web-Terminal der interaktiven Agent-CLI (Ersatz für AnythingLLM-Chat).
# Wird in MC2 per iframe eingebettet (Terminal-Seite). Siehe deploy/hermes-terminal.service.
HERMES_TERMINAL_URL = os.environ.get("MC_HERMES_TERMINAL_URL", "http://192.168.178.151:7681").rstrip("/")
# Box-Konsole: zweites ttyd-Web-Terminal, das eine echte Login-Shell auf der Box öffnet
# (direkter SSH-artiger Zugriff, kein Passwort — gleiches LAN-Trust-Modell wie das Hermes-
# Terminal). Wird in MC2 per iframe eingebettet (Konsole-Seite). Siehe deploy/box-console.service.
BOX_CONSOLE_URL = os.environ.get("MC_BOX_CONSOLE_URL", "http://192.168.178.151:7682").rstrip("/")
# Box-Konsole: zweites ttyd-Web-Terminal (echte Login-Shell). Bindet NUR an Loopback
# (127.0.0.1:7682, base-path /console) und wird von MC2 über den ohnehin offenen Port 9001
# rückwärts geproxyt (routers/console.py → same-origin /console/). So braucht die Konsole
# KEINE eigene Firewall-Freigabe (Port 7682 ist von außen dicht) und keinen sudo-Eingriff.
# Direkter, SSH-artiger Zugriff, kein Passwort — gleiches LAN-Trust-Modell wie das Dashboard.
BOX_CONSOLE_UPSTREAM = os.environ.get("MC_BOX_CONSOLE_UPSTREAM", "http://127.0.0.1:7682").rstrip("/")
# Öffentlicher, gleicher-Ursprung-Pfad, unter dem MC2 die Konsole ausliefert (iframe-Ziel).
BOX_CONSOLE_PATH = "/console/"
# GitHub-Repo für Update-Checks.
HERMES_AGENT_REPO = os.environ.get("MC_HERMES_AGENT_REPO", "NousResearch/hermes-agent")
HERMES_HOME = Path(os.path.expanduser(os.environ.get("HERMES_HOME", "~/.hermes")))