Skip to content

GatewayRun

Operate

Run the gateway day to day: the admin CLI, more proxy nodes, upgrades, health checks and logs.

The admin CLI

chan-gateway-admin is the operator's view of the whole gateway. Run it as root, with the admin credentials the setup script wrote:

#set -a; . /etc/chan-gateway/admin.env; set +a
CommandDoes
overview --since 24hAccounts, devservers and OAuth2 sign-ins at a glance.
tunnel ps, proxy psLive devservers and proxy nodes. tunnel watch and proxy watch follow them.
tunnel kill alice <devserver-id>Force one devserver offline. It may dial again.
policy set alice --enabled --max-connected-devservers 3Limit one account's connected devservers.
policy suspend alice, policy resume aliceDisconnect an account's devservers and refuse new ones, keeping its tokens and its limit; then lift that.
user block alice@example.com --reason "..."Revoke every token of the account and refuse its sign-ins.
user audit alice@example.comThe account's sign-ins, refusals and blocks.
token list alice@example.com, token revoke <token-uuid>An account's access tokens.
session oauth ps --user aliceThe account's signed-in browser sessions.
fleet pause --drain, fleet resumeCut every session and tunnel at once, then admit again. fleet status shows which.

Add --json to any command for scripts. The exit code is 0 for success, 1 for an upstream or network error, 2 for a bad argument, and 3 for not found.

Details and limits
  • An account is found by its uuid, its email, or its username, tried in that order.
  • user unblock lets an account sign in again; its tokens stay revoked.
  • Deleting an account, with user delete or by its holder on the account page, also disconnects its devservers.
  • The controller caps every account at 100 connected devservers, MAX_DEVSERVERS_PER_USER in devserver-control.env; a policy limit applies within that.
  • admin.env points at loopback. On another layout, set each CHAN_ADMIN_*_URL to the service's internal address.
  • The admin README lists every command.

More proxy nodes

Point proxy.example.com at every node, through DNS or a TCP pass-through balancer, so that every devserver keeps the same tunnel URL. A balancer that terminates TLS carries every tunnel byte. A second node, p2, needs:

WhatWhere
DNS, a certificate and an edge for *.p2.proxy.example.com, as on The edge proxyOn p2
devserver-proxy, with DEVSERVER_PROXY_ID=p2, DEVSERVER_PROXY_BASE_URL=https://p2.proxy.example.com and a DEVSERVER_PROXY_TOKEN of its ownOn p2
p2=<its token> added to DEVSERVER_PROXY_CREDENTIALS, with ; between entries, then a restart of devserver-controldevserver-control.env
A path to identity's internal listener, 7004, and the controller's proxy listener, 7101Between p2 and the first server
Details and limits
  • The other values of p2's devserver-proxy.env, such as the verifying keys and IDENTITY_INTERNAL_TOKEN, are the first node's.
  • The controller expands each node id into its origin with DEVSERVER_PROXY_BASE_URL_TEMPLATE, and refuses a node whose DEVSERVER_PROXY_BASE_URL differs.
  • Every internal listener binds loopback. A bind on another address needs CHAN_GATEWAY_INTERNAL_TRANSPORT=protected-overlay, which asserts that an authenticated, encrypted network carries the traffic.
  • With WireGuard, each node also gets an interface and an agent. See WireGuard.

Upgrades

Every gateway service runs the same release, so upgrade them together.

  1. Set the release's database markers

    migrate.env, identity.env and profile.env each carry EXPECTED_SQLX_MIGRATION and DATABASE_ROLE_POLICY_VERSION lines. Set them to the values the new release's configure.sh writes: the packages refuse to install over any other.

  2. Stop identity and profile, and install

    $sudo systemctl stop chan-gateway-identity chan-gateway-profile sudo apt install ./chan-gateway-profile_*.deb ./chan-gateway-identity_*.deb \ ./chan-gateway-devserver-control_*.deb ./chan-gateway-devserver-proxy_*.deb \ ./chan-gateway-admin_*.deb
  3. Apply the schema and restart

    $sudo systemctl restart chan-gateway-migrate sudo systemctl restart chan-gateway-profile chan-gateway-identity \ chan-gateway-devserver-control chan-gateway-devserver-proxy
Details and limits
  • Restart the schema unit even when the release changes nothing in the database: a finished one-shot does not run again by itself.
  • Where identity and profile run on separate hosts, upgrade profile with the schema step, before identity or together with it.
  • The controller and the proxy nodes check at connect that they run the same release.
  • On each WireGuard node, install the agent package of the same release and restart chan-gateway-wireguard-agent.

Health and logs

CheckCommandHealthy
Every service's logjournalctl -u 'chan-gateway-*' -f
identity answerscurl http://127.0.0.1:7000/healthzok
profile answerscurl http://127.0.0.1:7001/healthzok
The controller is readycurl http://127.0.0.1:7003/readyzready; warming until it is
The proxy admits devserverscurl -s -o /dev/null -w '%{http_code}\n' -H 'Host: proxy.example.com' http://127.0.0.1:7002/readyz200; 503 until it does
Proxy nodes connectedchan-gateway-admin proxy psOne row per node
Fleet admissionchan-gateway-admin fleet statusNot paused
Details and limits
  • After a start, the controller refuses admissions and admin reads for about 30 seconds while the proxy nodes report in.
  • A proxy that loses the controller for longer than a grace period closes every tunnel and browser session; devservers dial again once it is back.
  • pool timed out while waiting for an open connection, with Postgres reachable, means Postgres ran out of connection slots: restart it with sudo systemctl restart postgresql.

The gateway README covers every service and its settings, and the gateway design the system.

Next