Self-hosting
Install
From a release of klang-server to a running install with its first admin, in eight steps.
1. Get the release
Each release is a tag of the repository. Clone the one you want and go into the kit:
git clone --branch v0.0.31 --depth 1 https://github.com/klang-gg/klang-server.git
cd klang-server/selfhostThe images of each release are on GitHub’s registry, named
ghcr.io/klang-gg/klang-<name>:<version> for api, gateway, bot-gateway, web and
admin, for linux/amd64 and linux/arm64. The other services use the official images of
Caddy, Postgres, Valkey, Silo and LiveKit, each at an exact version. The store (s3) adds one
line to Silo’s image, and Compose builds it by itself the first time it starts.
2. Create .env
cp .env.example .env
sh init-env.shinit-env.sh replaces every change-me with a fresh random secret and makes the file readable
only by you. The API, the gateways, Valkey and the S3 setup refuse to start if a change-me is
left.
.env holds the keys of your install. Never share it or commit it. Keep a copy with your
backups: without the same BETTER_AUTH_SECRET, WEBHOOK_TOKEN_KEY and
APP_SIGNING_KEY_KEY, a restored install signs everyone out and its webhooks and bot keys stop
working.
3. Fill it in
Open .env and set at least the four hostnames. Everything else is optional.
| Group | Variables | What to do |
|---|---|---|
| Hostnames | KLANG_DOMAIN, KLANG_ADMIN_DOMAIN, KLANG_FILES_DOMAIN, KLANG_VOICE_DOMAIN |
Required. The four of Requirements |
| Caddy | CADDY_GLOBAL_OPTIONS |
Recommended: email you@example.org, for Let’s Encrypt’s expiry notices |
| Caddy | HTTP_PORT, HTTPS_PORT |
Leave them commented for 80 and 443. Other ports are only for trying it out |
| Secrets | POSTGRES_PASSWORD, VALKEY_PASSWORD, BETTER_AUTH_SECRET, WEBHOOK_TOKEN_KEY, APP_SIGNING_KEY_KEY, IMAGE_PROXY_KEY, LIVEKIT_API_KEY, LIVEKIT_API_SECRET, S3_ROOT_USER, S3_ROOT_PASSWORD, S3_API_ACCESS_KEY, S3_API_SECRET_KEY |
Filled by init-env.sh. Don’t change them once the install is running |
| Voice | LIVEKIT_USE_EXTERNAL_IP, LIVEKIT_NODE_IP, LIVEKIT_TCP_PORT, LIVEKIT_UDP_PORT, LIVEKIT_TURN_PORT |
Usually as they are. See Voice and TURN |
SMTP_URL, EMAIL_FROM, RESEND_API_KEY |
Optional. See Email | |
| Your install | CONTACT_EMAIL, TERMS_URL, PRIVACY_URL |
Recommended. See Configuration |
| Features | BETA_CLOSED, DISCOVERY_ENABLED, BOTS_ENABLED, BOTS_BETA, KLIPY_API_KEY, IGDB_CLIENT_ID, IGDB_CLIENT_SECRET, GAMES_CATALOG_URL |
Optional. See Configuration |
| Limits | LIMIT_UPLOAD_MB, LIMIT_STORAGE_GB, LIMIT_SCREEN_SHARE, LIMIT_CAMERA, LIMIT_VOICE_KBPS, LIMIT_STREAMS_PER_CHANNEL |
Optional. Unset, 500 MB per file, 100 GB per person and the best quality |
| Against abuse | ANONYMOUS_SIGNUPS_PER_HOUR, GATEWAY_CONNECTIONS_PER_5_MIN, SIGNUP_SHARED_IP_MIN_DEVICES, SIGNUP_SHARED_IP_WINDOW_DAYS |
Optional. See Configuration |
| Reverse proxy | CADDY_TRUSTED_PROXIES, TRUST_PROXY_HOPS |
Only behind your own proxy. See Behind your own reverse proxy |
| Images | KLANG_IMAGES, KLANG_VERSION, LOG_LEVEL |
Leave them. KLANG_VERSION stays commented: the release you cloned names its images |
Who can sign up
By default anyone who reaches the app can create an account. For a private community (friends, a
club, a team), close it before you start: set BETA_CLOSED=true, and accounts can only be
created with an invite code. You still create the first account in step 6, with a code from the
command line.
4. Get the images
docker compose pullIt pulls this release’s images and the pinned images of the other services. s3 shows as
skipped, because Compose builds it.
Or build them from the repository instead (slower, see the requirements):
docker compose build5. Start it
docker compose up -d
docker compose psThe first start creates the database and runs the migrations (migrate), creates the bucket
(s3-init), and only then starts the API and the gateways. migrate and s3-init exit when
they’re done, so Exited (0) is right for them. Every other service should be running or
healthy within a minute. Caddy asks Let’s Encrypt for the four certificates as the first
requests arrive.
6. Register
Open https://<KLANG_DOMAIN> and create your account with a username, an email and a password.
With BETA_CLOSED=true, sign-up asks for an invite code. Make one for yourself first:
docker compose exec api node dist/cli/beta.js create 1It prints a code like K7QPM-2XRTD, good for one account. Later you make the codes for other
people in the panel, under Closed beta.
7. Make it the admin
docker compose exec api node dist/cli/create-admin.js <your username or email>It works once: it makes the account you name the admin (a registered account with a password, not a guest one) and refuses when there’s already an admin. Other staff members are added from the panel, which keeps a record of who did it.
8. Open the panel
Go to https://<KLANG_ADMIN_DOMAIN> and sign in with the same account. The first time, the panel
asks you to set up two-factor authentication with an authenticator app (it asks for your
password first). Every staff action needs it.
Next: Configuration, and set up backups before people start using it.