Skip to content

GatewaySet up

Configure

Run the setup script, apply the database schema, and start the gateway services.

Run the setup script

The repository's setup script generates every service credential and signing key, prepares the database roles, and writes the configuration under /etc/chan-gateway/. Run it from a checkout of the same release:

$git clone --depth 1 --branch v0.133.0 https://github.com/fiorix/chan sudo chan/packaging/gateway/scripts/configure.sh

Answer its questions like this:

QuestionAnswer
Postgres user, password, databasechan, the password you chose, chan_gateway
Gateway public originhttps://gw.example.com
Proxy namespace originhttps://proxy.example.com
Tunnel ingress originEnter, for https://proxy.example.com
This proxy node idEnter, for p1
This proxy node originEnter, for https://p1.proxy.example.com
WireGuard ingressesEnter, which leaves WireGuard enrollment off. WireGuard turns it on later.
GitHub OAuth Client ID and Client SecretFrom the OAuth app. Enter skips Google and GitLab.

An origin is http:// or https://, a host and an optional port, with no path and no trailing slash. An answer the script refuses stops it before it changes anything; run it again.

Details and limits
  • The gateway public origin and the proxy namespace origin have no default.
  • With the WireGuard agent's package installed, the script also asks Kernel WireGuard interface for the agent, wg0 by default.
  • It ends by printing each provider's callback URL and the names that need DNS records and certificates, to check against Plan.
  • Every run asks every question again, generates new credentials and signing keys, and replaces each file whole, keeping the old one beside it as <file>.bak.<date>-<time>, readable by root only. On a running gateway, edit the files instead.
  • The one value a run takes from the files it replaces is the default answer to the WireGuard address pool question.
  • On a rerun, stop chan-gateway-identity and chan-gateway-profile before restarting the schema unit, as the script's closing lines say.
  • An existing env file the script cannot read stops it before the first question.

What it writes

File in /etc/chan-gateway/Read by
domain.envidentity, devserver-control and devserver-proxy: the public origins
migrate.envThe schema unit: the database owner's credentials
profile.env, identity.envprofile and identity, each with a database role of its own
devserver-control.env, devserver-proxy.envThe controller and this proxy node
admin.envchan-gateway-admin; readable by root only
wireguard-agent.envThe WireGuard agent; written only when its package is installed

Start the services

Apply the database schema, then start the services:

$sudo systemctl restart chan-gateway-migrate sudo systemctl enable --now chan-gateway-profile chan-gateway-identity \ chan-gateway-devserver-control chan-gateway-devserver-proxy

The schema unit runs once and must succeed before identity and profile start. Run it again after each upgrade, even when nothing changed.

Check them

Follow every service's log:

$journalctl -u 'chan-gateway-*' -f

The proxy admits devservers about 30 seconds after the controller comes up. Ask it, with the tunnel ingress name as the host:

$curl -s -o /dev/null -w '%{http_code}\n' -H 'Host: proxy.example.com' http://127.0.0.1:7002/readyz
200

It answers 503 until it is ready, and 404 to any other host name.

Next