You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Let the Linux service installer configure reverse-proxy hostnames #844
When Codeman runs as a Linux systemd user service behind a reverse proxy, the browser-facing hostname needs to be in CODEMAN_ALLOWED_HOSTS. The existing setting covers both HTTP and terminal WebSockets. Today, persisting it for an installer-managed service takes a manual systemd drop-in.
Would an optional Reverse proxy hostnames prompt and matching noninteractive flag (for example, --allowed-hosts codeman.example.com) fit the Linux service installer?
Reuse CODEMAN_ALLOWED_HOSTS and its existing comma-separated hostname syntax. Use an exact hostname in the prompt example.
Apply this setting only when explicitly supplied. Keep it in a drop-in outside the app checkout, and preserve existing allowed hosts and user-managed overrides on reinstalls and updates.
Keep the current bind, authentication, Host, and Origin behavior. DNS, TLS, and proxy configuration stay with the operator.
I verified the manual drop-in on an installer-managed Linux instance. The dashboard and terminal WebSocket worked through the custom hostname, and the terminal rejected an unrelated origin. Happy to send an implementation PR if this fits.
I checked this against master (1.51.1), and you're right about the gap:
install.sh never mentions CODEMAN_ALLOWED_HOSTS. setup_systemd_service() writes ~/.config/systemd/user/codeman-web.service from scratch each time, and the only Codeman variables it puts in are CODEMAN_HOST, CODEMAN_PASSWORD, CODEMAN_ALLOW_UNAUTHENTICATED_NETWORK, CODEMAN_BASE_URL and CODEMAN_PORT. An Environment= line you add to the unit by hand is gone the next time the installer writes the service. That happens on any full re-run that sets up the service (answering yes to the service question, or passing --service), and when install.sh tailscale or install.sh name changes the serve sub-path. The quiet install.sh update and App Settings > Updates only restart the service and leave the unit alone.
install.sh never touches ~/.config/systemd/user/codeman-web.service.d/, so your drop-in survives all of that. install.sh uninstall deletes the unit but leaves that directory in place.
On the server, one host policy from buildHostPolicy() (src/web/network-auth-policy.ts) gates HTTP (src/web/middleware/auth.ts), the terminal WebSocket (src/web/routes/ws-routes.ts) and the voice WebSocket (src/web/routes/voice-routes.ts). So, as you found, the environment variable is all the service needs.
codeman service install (the npm-install route, src/service-installer.ts) has the same gap. It rewrites the whole unit, and buildServiceEnv() writes only PATH, HOME, LANG and CODEMAN_INSTANCE. The Docker Compose deployment already forwards the variable (docker/docker-compose.yaml).
It's still open whether the installer should take this on, and in what shape. That depends on a few things:
install.sh promises "at most three questions" (in its header and in the README). A new prompt and a flag-only option (with an environment-variable twin, like the other flags) are different changes.
A drop-in file would be a new pattern. Every setting the installer writes today is an Environment= line in the unit, read back on re-runs by read_existing_binding().
Whether codeman service install and the macOS LaunchAgent should get the same option, and whether uninstall should remove a drop-in the installer created.
Whichever shape it takes, the value lands in a unit file, and systemd_env_escape() only escapes \ and ". The hostname list would need checking before it is written, because a newline in it would add a directive to the unit.
For now, your drop-in is the setup that survives reinstalls and updates.
Thanks for checking both installer paths and confirming that the drop-in survives reinstalls. Would you be open to a Linux install.sh PR that adds --allowed-hosts and a CODEMAN_ALLOWED_HOSTS environment variable without adding a fourth question?
I’d also like users to be able to change the list after installation. Would you prefer an install.sh allowed-hosts command to show, replace, or clear the installer-managed list, or should users re-run the installer with the flag? Either way, I’d validate the hostname list before writing it to a dedicated drop-in and leave user-managed overrides alone.
Longer term, it might be useful to show the active list in the Remote Access settings and eventually let admins edit it there. I’d keep that out of the first PR.
It's still open whether install.sh takes this on and in what shape: a flag only, a flag plus an install.sh allowed-hosts subcommand, or changing the list by re-running. Whether it should also cover the macOS LaunchAgent and codeman service install is open too. So I can't say yet which PR would fit, but here is what I checked on master (1.51.1) that bears on the choice.
For a flag without a fourth question: every flag in parse_flags() sets the same variable as its environment twin, and the ones whose value lives in the unit (--port, --password) also set RECONFIGURE=1, so a re-run with them takes the full flow instead of the quiet update. A new flag has to be in the header comment of install.sh (the "documents every flag it parses" test in test/install-sh-invariants.test.ts checks this) and in usage().
Changing the list by re-running with a flag is a full pass: npm run build, a rewritten codeman-web.service, and, in an interactive run, every question no flag answered (Enter keeps the current setup). For a subcommand, the closest existing one is install.sh name [<n>], which takes one positional argument in parse_flags(). Either way the server reads CODEMAN_ALLOWED_HOSTS from its environment (buildHostPolicy() in src/web/network-auth-policy.ts), so a new list applies once the service restarts.
Nothing in install.sh reads or writes codeman-web.service.d/ today. read_existing_binding() reads settings back from the unit only, and install.sh uninstall removes the unit file but leaves that folder. systemd applies drop-ins in lexicographic order of file name, and a later Environment= for the same variable wins (systemd.unit(5), systemd.exec(5)). An override.conf written by systemctl --user edit sorts after a file such as codeman-allowed-hosts.conf, so a user's own value wins over the installer's. It also means a show command that reads only the installer's file would not always show the list the service runs with.
On validation, the server strips the port from the request's Host (parseAuthorityHostname()) and compares the hostname with each entry exactly, or as a suffix for a leading-dot entry (matchesHost()). An entry with a scheme, a port or a path (https://codeman.example.com, codeman.example.com:8443) is accepted at startup and never matches anything. Allowing only hostname characters (letters, digits, - and ., with an optional leading . per entry) catches those, the newline case from my earlier comment, and %, which systemd expands as a specifier inside Environment=.
The "Remote access" group in App Settings has the Cloudflare Tunnel switch and its URL, and nothing in the UI shows this list. The server prints it once at startup (Host allowlist also accepts: ..., visible with journalctl --user -u codeman-web). Editing it there would need a source other than the service environment.
Until this is decided, the drop-in that #845 documents is the setup that survives reinstalls and updates.
Activity
Ark0N commentedon Nov 22, 2026
Thanks for the detailed write-up.
I checked this against master (1.51.1), and you're right about the gap:
install.shnever mentionsCODEMAN_ALLOWED_HOSTS.setup_systemd_service()writes~/.config/systemd/user/codeman-web.servicefrom scratch each time, and the only Codeman variables it puts in areCODEMAN_HOST,CODEMAN_PASSWORD,CODEMAN_ALLOW_UNAUTHENTICATED_NETWORK,CODEMAN_BASE_URLandCODEMAN_PORT. AnEnvironment=line you add to the unit by hand is gone the next time the installer writes the service. That happens on any full re-run that sets up the service (answering yes to the service question, or passing--service), and wheninstall.sh tailscaleorinstall.sh namechanges the serve sub-path. The quietinstall.sh updateand App Settings > Updates only restart the service and leave the unit alone.install.shnever touches~/.config/systemd/user/codeman-web.service.d/, so your drop-in survives all of that.install.sh uninstalldeletes the unit but leaves that directory in place.buildHostPolicy()(src/web/network-auth-policy.ts) gates HTTP (src/web/middleware/auth.ts), the terminal WebSocket (src/web/routes/ws-routes.ts) and the voice WebSocket (src/web/routes/voice-routes.ts). So, as you found, the environment variable is all the service needs.codeman service install(the npm-install route,src/service-installer.ts) has the same gap. It rewrites the whole unit, andbuildServiceEnv()writes onlyPATH,HOME,LANGandCODEMAN_INSTANCE. The Docker Compose deployment already forwards the variable (docker/docker-compose.yaml).It's still open whether the installer should take this on, and in what shape. That depends on a few things:
install.shpromises "at most three questions" (in its header and in the README). A new prompt and a flag-only option (with an environment-variable twin, like the other flags) are different changes.Environment=line in the unit, read back on re-runs byread_existing_binding().codeman service installand the macOS LaunchAgent should get the same option, and whetheruninstallshould remove a drop-in the installer created.Whichever shape it takes, the value lands in a unit file, and
systemd_env_escape()only escapes\and". The hostname list would need checking before it is written, because a newline in it would add a directive to the unit.For now, your drop-in is the setup that survives reinstalls and updates.
bearyjd commentedon Nov 22, 2026
Thanks for checking both installer paths and confirming that the drop-in survives reinstalls. Would you be open to a Linux
install.shPR that adds--allowed-hostsand aCODEMAN_ALLOWED_HOSTSenvironment variable without adding a fourth question?I’d also like users to be able to change the list after installation. Would you prefer an
install.sh allowed-hostscommand to show, replace, or clear the installer-managed list, or should users re-run the installer with the flag? Either way, I’d validate the hostname list before writing it to a dedicated drop-in and leave user-managed overrides alone.Longer term, it might be useful to show the active list in the Remote Access settings and eventually let admins edit it there. I’d keep that out of the first PR.
Ark0N commentedon Nov 22, 2026
Thanks for the follow-up.
It's still open whether
install.shtakes this on and in what shape: a flag only, a flag plus aninstall.sh allowed-hostssubcommand, or changing the list by re-running. Whether it should also cover the macOS LaunchAgent andcodeman service installis open too. So I can't say yet which PR would fit, but here is what I checked on master (1.51.1) that bears on the choice.For a flag without a fourth question: every flag in
parse_flags()sets the same variable as its environment twin, and the ones whose value lives in the unit (--port,--password) also setRECONFIGURE=1, so a re-run with them takes the full flow instead of the quiet update. A new flag has to be in the header comment ofinstall.sh(the "documents every flag it parses" test intest/install-sh-invariants.test.tschecks this) and inusage().Changing the list by re-running with a flag is a full pass:
npm run build, a rewrittencodeman-web.service, and, in an interactive run, every question no flag answered (Enter keeps the current setup). For a subcommand, the closest existing one isinstall.sh name [<n>], which takes one positional argument inparse_flags(). Either way the server readsCODEMAN_ALLOWED_HOSTSfrom its environment (buildHostPolicy()insrc/web/network-auth-policy.ts), so a new list applies once the service restarts.Nothing in
install.shreads or writescodeman-web.service.d/today.read_existing_binding()reads settings back from the unit only, andinstall.sh uninstallremoves the unit file but leaves that folder. systemd applies drop-ins in lexicographic order of file name, and a laterEnvironment=for the same variable wins (systemd.unit(5),systemd.exec(5)). Anoverride.confwritten bysystemctl --user editsorts after a file such ascodeman-allowed-hosts.conf, so a user's own value wins over the installer's. It also means a show command that reads only the installer's file would not always show the list the service runs with.On validation, the server strips the port from the request's
Host(parseAuthorityHostname()) and compares the hostname with each entry exactly, or as a suffix for a leading-dot entry (matchesHost()). An entry with a scheme, a port or a path (https://codeman.example.com,codeman.example.com:8443) is accepted at startup and never matches anything. Allowing only hostname characters (letters, digits,-and., with an optional leading.per entry) catches those, the newline case from my earlier comment, and%, which systemd expands as a specifier insideEnvironment=.The "Remote access" group in App Settings has the Cloudflare Tunnel switch and its URL, and nothing in the UI shows this list. The server prints it once at startup (
Host allowlist also accepts: ..., visible withjournalctl --user -u codeman-web). Editing it there would need a source other than the service environment.Until this is decided, the drop-in that #845 documents is the setup that survives reinstalls and updates.