Skip to content

GatewaySet up

Plan and prerequisites

What a gateway runs, and the server, DNS records, certificate and OAuth app it needs before you install.

The work, in order

The pages set up one gateway on one Ubuntu 24.04 server. example.com stands for your domain throughout.

PhaseWhat it answersWhat you finish with
Plan, this pageWhat do I need before I start?A server, three DNS records, a wildcard certificate, an OAuth app
InstallWhich packages, and where does the data live?Postgres with the gateway database, and the service packages
ConfigureHow do the services find each other and their public names?The configuration under /etc/chan-gateway/, and the services running
The edge proxyHow does traffic from the internet reach the services?nginx terminating TLS for the three names
Accounts and OAuth2 sign-inWho may sign in?Your own account, signed in, with its username set
Publish a devserverDoes it work end to end?A devserver online, opened in a browser, and shared
WireGuard, optionalCan desktops reach the proxy nodes through WireGuard?Desktops enrolled at sign-in
OperateHow do I run it from day to day?The admin CLI, more nodes, upgrades, health checks

What you run

A gateway is a few small services, a Postgres database and a TLS edge in front. Each service listens on loopback; the edge publishes only what must be public.

ServiceDoesReached at
identityOAuth2 sign-in with GitHub, Google or GitLab, the account page, access tokens, sharing, the desktop's sign-ingw.example.com
profileAccounts, devservers, shares and policy, in PostgresInternal only
devserver-controlAdmits devservers and tracks the proxy nodes. No devserver traffic crosses it.Internal only
devserver-proxyTakes the devservers' tunnels and serves each devserver at an origin of its ownproxy.example.com, *.p1.proxy.example.com
wireguard-agentOptional: keeps a proxy node's WireGuard peers in step with the gatewayNo listener
chan-gateway-adminThe operator's command lineRun as root on the server

A devserver's machine needs no inbound port, DNS name or certificate: it dials out to the gateway with an access token. The gateway guide draws the traffic.

Details and limits
  • gw.chan.app is the maintainer's own deployment of this code: experimental, with OAuth2 sign-in off by default. It is not a hosted product and takes no sign-ups.
  • To run the services on Kubernetes instead of one server, follow packaging/kube. The WireGuard agent has no manifest, since it changes the host's own network interface.

What you need

You needForWho provides it
A server: Ubuntu 24.04, amd64 or arm64, TCP ports 80 and 443 openEvery service, Postgres and nginxYou, with sudo on it
A domain whose DNS you controlThe three names belowWhoever manages the domain's DNS
An API credential at your DNS providerThe DNS challenge a wildcard certificate needsThe DNS provider's account
An OAuth app at GitHub, Google or GitLabOAuth2 sign-inAn account at that provider, or an admin of its organization
UDP port 51820 open, only for WireGuardDesktops' WireGuard tunnelsYou, at the server's firewall

DNS and a certificate

Point three records at the server:

NameServes
gw.example.comOAuth2 sign-in, accounts, and desktop discovery.
proxy.example.comTunnel ingress, where devservers dial in, and proxy health.
*.p1.proxy.example.comOne origin per devserver on proxy node p1. A *.example.com record does not cover these names.

The services speak plain HTTP on loopback, and nginx terminates TLS in front of them. The wildcard name needs a certificate from a DNS challenge, so install certbot with the plugin for your DNS provider. With Cloudflare:

$sudo apt install certbot python3-certbot-dns-cloudflare sudo certbot certonly --dns-cloudflare \ --dns-cloudflare-credentials /root/cloudflare.ini \ -d gw.example.com -d proxy.example.com -d '*.p1.proxy.example.com'

The certificate lands in /etc/letsencrypt/live/gw.example.com/, where the edge configuration reads it, and certbot renews it on its own.

Details and limits
  • With WireGuard, p1.proxy.example.com needs a record of its own: desktops dial it, and the wildcard record does not cover the name itself.
  • Each further proxy node adds a wildcard of its own, such as *.p2.proxy.example.com. See More proxy nodes.
  • A certificate from a CA of your own works for a gateway on an internal network. Install that CA in the system trust store of every machine that runs Chan Desktop, a devserver or the WireGuard agent.
  • On macOS and Windows, chan verifies the gateway through the system, as a browser does. On Linux it reads the system's CA bundle (update-ca-certificates on Debian and Ubuntu, update-ca-trust on Fedora) beside the roots it carries.
  • chan reads the trust store when it starts: restart a running desktop, devserver or agent after installing a CA.

An OAuth2 sign-in provider

The gateway needs at least one of GitHub, Google and GitLab. For GitHub, open Developer settings, choose New OAuth App, and set:

FieldValue
Homepage URLhttps://gw.example.com
Authorization callback URLhttps://gw.example.com/auth/github/callback

Keep the client ID and a client secret for Configure. For Google or GitLab, the callback ends in /auth/google/callback or /auth/gitlab/callback.

Next