fix: support proxied dashboard chat sessions - #21104
Conversation
Remove systemd restart directives unsupported by older systemd releases. Trust local reverse proxy headers for the dashboard and allow proxied WebSocket requests when the upstream Host header matches the bound dashboard host. Update the TUI build freshness check to use the actual @hermes/ink build artifact so embedded chat startup does not rebuild on every PTY connection.
|
Added a follow-up commit Additional validation:
|
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the focused compatibility and dashboard investigation. The systemd, TUI-staleness, and session-list portions have since landed through later changes, but the reverse-proxy portion needs a narrower rework.
Problems
hermes_cli/web_server.py:2920changes only the peer-IP predicate. The WebSocket Host/Origin gate is separate and runs first on current main athermes_cli/web_server.py:14335; it still rejects a public browser Origin for a loopback-bound dashboard. The linked #54072 discussion confirms this exact gap in this PR.hermes_cli/web_server.py:4086enablesproxy_headersfor every bind. Current main deliberately keeps it disabled for loopback binds and enables it only for authenticated public binds (hermes_cli/web_server.py:17030-17037) to preserve the loopback peer boundary.
Suggested changes
- Salvage the remaining proxy case through the existing Host/Origin policy and configured trusted public URL, with end-to-end WebSocket coverage for both acceptance and rejection cases.
- Keep the current conditional
proxy_headerspolicy; omit portions already superseded by4d18717b6andc6ca11618.
Automated hermes-sweeper review.
|
|
||
| bound_host = getattr(app.state, "bound_host", "") | ||
| host_header = ws.headers.get("host", "") | ||
| if bound_host and _is_accepted_host(host_header, bound_host): |
There was a problem hiding this comment.
This changes only the peer-IP check. A normal public reverse proxy still presents a browser Origin for its public hostname, while the separate Host/Origin guard compares that Origin to the loopback bound_host; this PR does not modify that path, so the reported origin_mismatch remains. Please route the configured trusted public URL through the Host/Origin policy rather than bypassing this peer check.
| host=host, | ||
| port=port, | ||
| log_level="warning", | ||
| proxy_headers=True, |
There was a problem hiding this comment.
Do not enable proxy headers unconditionally for loopback binds. The current design keeps the loopback peer as the security boundary and enables forwarded-header handling only for authenticated public binds; preserve that distinction when salvaging the proxy case.
Summary
entry-exports.js)/sessionspageDetails
RestartMaxDelaySec/RestartStepsfrom the generated gateway systemd unit so it works on older systemd versions (e.g. systemd 245).proxy_headers=Trueandforwarded_allow_ips="127.0.0.1,::1"so local reverse proxies can pass through the original client/host information without trusting arbitrary remote forwarded headers./api/ptyWebSocket handshakes from a trusted local reverse proxy when the forwarded/Host header still matches the dashboard bind host, while preserving the DNS-rebinding guard for non-loopback clients._hermes_ink_bundle_stale()to checkui-tui/packages/hermes-ink/dist/entry-exports.jsinstead of the removedink-bundle.js, avoiding needless rebuilds during dashboard chat connection startup./api/sessionsprojects to the latest live tip even when an intermediate compression anchor itself has a parent, and sorts dashboard sessions by last activity.Test Plan
venv/bin/python -m pytest tests/hermes_cli/test_gateway.py tests/hermes_cli/test_tui_npm_install.py tests/hermes_cli/test_web_server_host_header.py tests/hermes_cli/test_web_server.py::TestPtyWebSocket -q -o 'addopts='venv/bin/python -m pytest tests/test_hermes_state.py::TestListSessionsRich tests/test_hermes_state.py::TestCompressionChainProjection tests/hermes_cli/test_web_server.py::TestPtyWebSocket tests/hermes_cli/test_web_server_host_header.py -q -o 'addopts='/api/ptyWebSocket handshake returnedHTTP/1.1 101 Switching Protocols./api/sessions?limit=20&offset=0check confirmed a repeatedly-compressed active session now appears in the first page.Note
The TUI artifact freshness change overlaps with existing PRs called out in review (#20951, #20686, #21098). The systemd/reverse-proxy/session-list fixes are independent.