Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.
TypeScript browser-shellcontrol-planefile-managerhomelabmobile-firstnextjsptyreactself-hostedserver-managementshadcn-uisysadmintailwindcssterminaltypescriptvpsweb-desktopweb-terminal
fix(proxy): finish portable managed-app loopback relay
Rahman1d7e6c48dd94
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.mdindex 0fd10994..cc6aa747 100644--- a/docs/CHANGELOG.md+++ b/docs/CHANGELOG.md@@ -13,6 +13,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.**Fixed**+- `proxy` finish portable managed-app loopback relay- `workflows` pin private storage reads and atomic writes- `ci` preserve strict scanner coverage on hosted release- `forge` make sandbox bootstrap portable on hosted Linuxdiff --git a/docs/PROGRESS.md b/docs/PROGRESS.mdindex 13303b26..fa0cf9af 100644--- a/docs/PROGRESS.md+++ b/docs/PROGRESS.md@@ -1,3 +1,18 @@+## 2026-09-17 — Finish the verified branch release and loopback managed-app relay++The release audit reconciled the dormant Workflow/Organization controls, exact artifact history,+private-store hardening and bundle work through PR #47 rather than rewriting their source branches.+All candidate changes were already gated; this handoff independently rechecked 83 targeted tests,+typecheck and current PR checks before integration. Dirty worktrees, stashes, historical alternatives+and recovery refs remain preserved; an old branch name alone is not evidence of a missing feature.++The remaining managed-app relay patch was reproduced with a failing reverse-proxy test, then applied+from the preserved source after reviewing its two-file delta. Public HTTPS headers can describe an+HTTP loopback Next listener as HTTPS; internal managed-app rewrites now correct only loopback+transport while retaining the public scheme for non-loopback origins. Regression cases cover+localhost, IPv4 and IPv6 loopback, query preservation and unchanged public-host/cross-origin guards.+There is no bind-address change, provider requirement or weakening of managed-app isolation.+## 2026-09-17 — Lock-fixture cleanup prevents accumulated test processesThe branch/worktree audit found orphaned `mso-lock-holder` shells and `sleep` children from completed gateway boundary tests. The fixture killed only the forking `flock` parent, leaving the command and inherited lock descriptor alive after its temporary directory was removed. The holder now uses `flock --no-fork` with a single Node process; readiness is inside `try/finally`, and the regression asserts exact PID identity, process exit and kernel-lock reacquisition. No gateway/provider runtime behavior or release guard is changed. Historical process cleanup is restricted to verified orphan fixtures from this conversation's worktrees, not other agents or production processes.diff --git a/proxy.ts b/proxy.tsindex d782b627..955044df 100644--- a/proxy.ts+++ b/proxy.ts@@ -96,6 +96,17 @@ function notFound() {});}+// Reverse proxies correctly preserve the public HTTPS scheme in x-forwarded-proto,+// and Next folds that into nextUrl.origin even though this Next process itself is+// listening on plain HTTP loopback. Rewriting to that synthetic https://localhost+// origin makes Next open TLS to its own HTTP socket and fail with EPROTO. Keep the+// public scheme everywhere else, but use the actual transport for a loopback rewrite.+function internalRewriteOrigin(request: NextRequest): URL {+ const origin = new URL(request.nextUrl.origin);+ if (LOOPBACK_HOST.test(origin.hostname)) origin.protocol = "http:";+ return origin;+}+// Extracted so the app-host branch can apply the SAME rule: after its rewrite the// path starts with /api/, i.e. past the point where this gate would have run.function crossOriginMutation(request: NextRequest): boolean {@@ -269,18 +280,15 @@ export async function proxy(request: NextRequest) {// trailing slash away before middleware even runs, and re-adding one here would// send that redirect back to this host to be rewritten a second time, one prefix// deeper. Two traps in building this URL:- // • the origin must be the one NEXT derived for this request (nextUrl's: bind- // host + x-forwarded-proto, NOT the public Host). A rewrite stays internal- // only while the destination's origin matches that; otherwise Next PROXIES- // the destination — i.e. opens an https socket to this server's plain http- // port and dies with EPROTO. `next start --hostname 0.0.0.0` (how the unit- // starts it) agrees with itself here; `--hostname 127.0.0.1` does NOT, and- // every rewrite 500s under it.+ // • use the local transport for a loopback nextUrl origin. Reverse proxies set+ // x-forwarded-proto=https, which can make Next describe its own plain-HTTP+ // listener as https://localhost:PORT. internalRewriteOrigin() corrects only+ // that loopback mismatch; a real public/non-loopback origin keeps its scheme.// • a plain URL, not nextUrl.clone(): NextURL remembers the incoming trailing// slash and puts it back when the pathname is reassigned.const path = `${proxyPrefix(managedApp)}${pathname.replace(/\/+$/, "")}`;return NextResponse.rewrite(- new URL(`${path}${request.nextUrl.search}`, request.nextUrl.origin),+ new URL(`${path}${request.nextUrl.search}`, internalRewriteOrigin(request)),{request: { headers },},diff --git a/scripts/managed-app-loopback.test.ts b/scripts/managed-app-loopback.test.tsnew file mode 100644index 00000000..2b3a33cf--- /dev/null+++ b/scripts/managed-app-loopback.test.ts@@ -0,0 +1,26 @@+import { afterEach, describe, expect, it, vi } from "vitest";+import { NextRequest } from "next/server";++const TEMPLATE = "{id}.mso.example.com";+const HERMES = "/api/v1/managed-apps/hermes/proxy";+const rewriteOf = (res: Response) => res.headers.get("x-middleware-rewrite");+async function loadProxy(template: string) {+ vi.resetModules();+ vi.stubEnv("NEXT_PUBLIC_MANAGED_APP_HOST_TEMPLATE", template);+ return (await import("../proxy")).proxy;+}+afterEach(() => vi.unstubAllEnvs());++describe("managed-app internal transport behind HTTPS termination", () => {+ it.each(["localhost", "127.0.0.1", "[::1]"])("keeps reverse-proxy rewrites to %s on local HTTP", async host => {+ const proxy = await loadProxy(TEMPLATE);+ for (const protocol of ["http", "https"]) {+ const request = new NextRequest(`${protocol}://${host}:4005/chat?from=edge`, {+ headers: { host: "hermes.mso.example.com", "x-forwarded-proto": "https" },+ });+ const res = await proxy(request);+ expect(rewriteOf(res)).toBe(`http://${request.nextUrl.host}${HERMES}/chat?from=edge`);+ }+ });++});