Skip to content

fix: nginx starts without a browser sidecar, and hand edits survive restart - #98

Merged
andrasbacsai merged 1 commit into
mainfrom
cursor/fix-browser-nginx-and-config-persist-3d99
Oct 19, 2026
Merged

andrasbacsai merged 1 commit into
mainfrom
cursor/fix-browser-nginx-and-config-persist-3d99

Conversation

@andrasbacsai

Copy link
Copy Markdown
Member

Fixes #39.

Related to #15. This does not claim to close #15. That issue is about restarting the gateway from inside the container. The hand-edit loss below is the same class of “config disappears on restart” report.

1. nginx starts with no browser host

location /browser/ used proxy_pass http://browser:3000/, which nginx resolves at startup. A plain docker run has no such host, so nginx exited with host not found in upstream "browser".

The location now uses Docker’s DNS resolver and a variable proxy_pass, so a missing sidecar returns 502 and nginx still starts. /browser/ stays on basic auth and is not part of the bearer bypass. docker run --add-host only writes /etc/hosts, which that resolver does not read, so when getent can already resolve browser the address is pinned (compose DNS and --add-host both work). The /browser/ prefix is stripped.

2. Hand-edited top-level keys

OpenClaw 2026.10.5 validates openclaw.json with z.strictObject. openclaw doctor --fix rewrites the file through that schema and drops unrecognized keys. gateway run then exits if an unrecognized key is still present at process start. After the gateway is listening, the same key only produces config reload skipped (invalid config) and the process keeps the valid config it loaded.

--lint and --json are read-only, so they do not apply the migrations this entrypoint has always used --fix for. Skipping doctor after the first boot also fails: configure.js reapplies env values on every start (including a model id doctor then upgrades, such as anthropic/claude-sonnet-4-5 → anthropic/claude-sonnet-4-6). Without doctor, the gateway exits on the unmigrated value.

So doctor still runs on every start. Before it runs, the entrypoint snapshots the file. After the gateway is listening, scripts/preserve-hand-edits.js writes back only top-level keys doctor removed. Nested env-driven settings and doctor migrations stay as doctor left them.

gateway.controlUi.allowInsecureAuth is no longer written. 2026.10.5 rejects that key, which is why device approval is required (below). Doctor was deleting it on every boot.

3. /__openclaw__/assistant-media stays on the bearer bypass

A request with no Authorization header gets 401 Basic. A bare URL with a Bearer token and no source is a gateway 404, for both a bogus token and the real gateway token. That 404 is a missing-source response, not an auth grant.

The Control UI does send Authorization: Bearer to this exact path, and that request has to skip basic auth or nginx re-prompts:

  • chat local-media metadata (?meta=1) in ui/src/e2e/chat-flow.local-media-policy.e2e.test.ts (OpenClaw v2026.10.5) expects Bearer and expects the follow-up media bytes to use mediaTicket with no Authorization header
  • browser screenshots and downloads set the header in ui/src/components/browser/browser-client.ts (fetchBrowserScreenshotDataUrl) and ui/src/components/browser/browser-panel-download.ts

Ticketed image/audio requests have no Bearer header, so they still require basic auth. The bypass map only skips auth when the header is Bearer and the path matches.

4. README

  • One-time device approval on 2026.10.5+: basic auth, then the wss:// URL and OPENCLAW_GATEWAY_TOKEN, then Approve this browser, then openclaw devices list and openclaw devices approve <requestId>. With no id, approve only previews and exits 1. Once per browser profile.
  • Auto-update is hourly (0 * * * *), not every 6 hours.

Verification

Image built as CI does: Dockerfile.base then Dockerfile, OPENCLAW_GIT_REF=v2026.10.5 (OpenClaw 2026.10.5 (1b58cb9)).

  • node scripts/utils.test.js — 292 passed
  • node scripts/nginx-bearer.test.js — 80 passed
  • (a) no browser host: nginx starts, / is 401 without credentials and 200 OpenClaw Control with basic auth, /browser/ with auth is 502, nginx stays up
  • (b) --add-host browser:127.0.0.1: upstream pinned to 127.0.0.1:3000, /browser/foo is 401 without auth and path=/foo with auth
  • (c) volume + docker restart: x-hand-edit is restored after the gateway listens, gateway.auth.token is still the env token, allowed origins still match the env, container stays up (config reload skipped (invalid config): Unrecognized key: "x-hand-edit")
  • (d) /__openclaw__/assistant-media with no credentials is 401 WWW-Authenticate: Basic
  • (e) Playwright: sign in with basic auth, connect with the gateway token, approve the device, Control UI loads (Assistant / Home). Zero 401 responses with WWW-Authenticate: Basic, and no auth dialog

Approve this browser
Control UI after device approval

Open in Web Open in Cursor 

Resolve the browser upstream at request time so nginx boots when no
sidecar exists, and write unrecognized top-level keys back after the
gateway has loaded so doctor --fix can still migrate on every start.

Co-authored-by: Andras Bacsai <[email protected]>
@andrasbacsai
andrasbacsai merged commit 00f85de into main Oct 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Browser sidecar is not really optional Unable to restart the gateway

2 participants