Expand description
Native reverse proxy for container-agent dev servers.
Routes http://<project>-<agent_id>.localhost:{DEV_PROXY_PORT}/... to
whatever internal ip:port that agent’s dev server registered via the
RegisterDevServer MCP tool (the HTTP endpoint backing that tool lives
in crates/srv/src/server/app_api/dev_server.rs; this module owns the
routing table and the proxy server itself). See
docs/specs/SPEC_NATIVE_CONTAINER_DEV_PROXY_2026_09_19.md.
Deliberately NOT a general-purpose reverse proxy (spec §4): Host-header
→ backend address is the entire feature. No path routing, no TLS, no
auth, no rate limiting. WebSocket upgrades are passed through (a dev server’s hot reload
needs one), and a container whose address the host cannot reach (Docker Desktop) is reached
through the relay in dev_relay.
Modules§
- forward
- One request through the dev proxy to a connection already open to the dev server, WebSocket upgrades included (Vite’s hot reload is one).
Structs§
- DevProxy
Registry "<project>-<agent_id>"→ the container’s internalip:portits dev server is actually listening on. Cleared per-agent when that agent’s container stops (ContainerManager::stop/removeincontainer.rscallunregister_container— see that module’scleanup_dev_proxy_routes).
Enums§
- Target
- How to reach a registered dev server.
Constants§
- DEV_
PROXY_ PORT - The local port the proxy tries first. Nothing else in
agentmux-srvbinds it (checked: no otherTcpListener::bindor config default references 8090 anywhere in this crate). See spec §5. A second instance on the same host finds it held and takes a free port instead;portsays which one this instance got.
Functions§
- port
- The port this instance’s proxy listens on: the one it bound, which is
DEV_PROXY_PORTunless another instance on the host held it. Before the proxy has bound, the preferred port is the best answer there is. - router
- Builds the proxy’s axum router. Split out from
serveso tests can drive it directly (via a real bound listener) without needing the fixedDEV_PROXY_PORTto be free. - routing_
key_ from_ host - Host header → routing key.
"pulse-korp.localhost:8090"and"pulse-korp.localhost"both become"pulse-korp". A Host that isn’t.localhostis still accepted (minus port, lowercased) rather than rejected outright — an empty/missing Host is the only thing that producesNone. Whether the key actually resolves to anything is the registry lookup’s job, not this function’s; either way the caller gets a clear “no dev server registered for<key>” 404, never a confusing hostname-format error. - serve
- Binds
DEV_PROXY_PORTon loopback (or a free port when another instance holds it) and serves the proxy until the process exits. Spawned once at srv startup (main.rs). A bind failure is logged and the proxy is simply unavailable for this run — never fatal to srv startup; dev-server routing is an additive convenience, not core functionality.