Black Branch/Docs
All sections

The homeserver

This page is a reference for an owner who wants to know how the chat server inside the install works. After it, you will know what the installer sets up, the decisions it makes for you, how sign-up works, and how to turn federation on correctly.

Every install runs its own Matrix homeserver: the chat server behind your community rooms, direct messages and every account on your site. What Matrix is and how your members use it is on Matrix (built in).

Two programs, one server

Part What it does Where it answers
Synapse The homeserver itself: rooms, messages, media, and talking to other servers when federation is on https://matrix.example.com/_matrix/…
MAS, the Matrix Authentication Service Accounts and sign-in: passwords, sign-up, and the tokens the site and Matrix apps use https://matrix.example.com/auth/

Synapse hands all of sign-in to MAS. When someone signs in to your site, the site sends them to MAS's page. MAS checks the password and sends them back with a token that works on Synapse. Matrix apps such as Element use the same sign-in. MAS also has an admin interface, which the setup pages use to make your admin account. It answers only inside the install's private network; nothing from the internet reaches it.

Both keep their data in the install's one Postgres server, each in its own database with its own password. Synapse keeps uploaded media and its signing key in its own storage volume.

The server name is your domain

The homeserver's server name is your bare domain, example.com, so accounts look like @casey:example.com, even though the server itself answers at matrix.example.com. Other software finds it through two small discovery files the site serves:

The server name is permanent: it is part of every account, room and message. See The domain.

The signing key

When it first starts, Synapse makes a signing key: the key it signs its messages with, which other servers use to know they really came from example.com. The install makes it once, keeps it in Synapse's storage volume, and never replaces it. Losing it cannot be undone: a new key makes your server look like a different server to everyone who knew the old one. That is why it is in every backup. MAS has signing keys of its own (/opt/blackbranch/matrix/mas-keys.yaml), made once and backed up the same way.

The configuration is generated

The configuration files for Synapse, MAS and the router are written by sudo blackbranch render from .env and two switches (federation and sign-up). They live in /opt/blackbranch/rendered/.

What the generated configuration decides:

Decision What it is set to Why
Federation Off on a new install See Federation: off by default
Sign-up Closed until setup is finished, then your choice So nobody can claim your community's room names before you make them
Email None on a new install; optional Without a mail server nothing is sent and sign-up asks for no address, because requiring an address nothing can verify would lock everyone out; a forgotten password is reset on the server (Resetting a password). With a mail server set in Admin Panel → Site → Site, card Mail, the sign-in page offers "Forgot password?" and a new account confirms its address by mail.
Message retention 180 days for any room without its own policy (every direct message, and #forum); a room may choose from 1 day to 1 year; #general is made with 30 days Keeps the server from filling up with years of chat, and limits how much old conversation exists at all
Upload size 20 MB per file Keeps one upload from filling the disk
Room version 12 The site's moderation relies on how version 12 treats room creators
Public room list Lists only your community space, #general and #forum So the server's directory cannot be filled with other rooms
Profiles Readable without signing in So avatars show for visitors who are not signed in

The community space and its rooms

The setup pages' Community step creates your community space (alias #community-hub:example.com) with two rooms, #general and #forum, signed in as your account, so you own them. All three are public and unencrypted. It looks before it creates, so running it again changes nothing. It never adopts a room it did not make: if one of the aliases already exists and was made by another account, it stops and says so. On the server the same step is sudo blackbranch matrix bootstrap.

The Forums tab and the Active threads widget read #forum through a read-only reader account. The install makes that account (its token is MATRIX_READER_TOKEN in .env) and checks it at every start, so both work from the first day.

Sign-up

During setup, sign-up on the homeserver is closed whatever the switch says; the setup pages make your account directly. Once setup is finished, sign-up follows your answer to Who can join?

To change it later, open Admin Panel → Site → Community, card Federation and sign-up, and set Let people make accounts to Yes or No. Only an admin can change it. Saving asks the server to render the configuration again, which takes a few seconds.

During a raid, lockdown's New signups lever (which mods can use) closes sign-up too, and puts your earlier value back when the lockdown lifts, unless you changed the switch yourself in the meantime. See Raid lockdown.

Federation: off by default

Federation is off on a new install. With it off, Synapse has no listener for other servers, and the router answers "not found" to any server-to-server request. Only accounts made on your site take part in your rooms.

Turning it on lets people with accounts on other Matrix servers join your public rooms and message your members, and lets your members join rooms elsewhere. It also means moderating people your site knows nothing about, and copies of messages in shared rooms living on other servers. The trade-offs are on Matrix (built in).

Federation is not the same as signing in with an account from another server, which lets a person with an account elsewhere sign in to your site without your server federating. That has its own card, Admin Panel → Site → Site, card Sign-in from other servers. See Your account.

Turning federation on correctly

  1. On the server, run sudo blackbranch federation on. It saves the setting, renders the configuration again and restarts Synapse. Or switch Federation in Admin Panel → Site → Community, card Federation and sign-up; saving it there asks the server for the same render.
  2. Run sudo blackbranch federation on its own to see the state.
  3. Open Admin Panel → Doctor: the row Federation matches its switch should say it is on and reachable.
  4. Check from outside with the Matrix federation tester, entering example.com.

Nothing extra has to be opened: other servers reach yours over HTTPS on port 443, through the same front door as everyone else.

Preview note: in tunnel mode, Cloudflare's bot protection may challenge or slow other servers' requests to matrix.example.com. If the federation tester passes but messages from other servers do not arrive, check Cloudflare's Security → Events for blocked requests to /_matrix/federation/.

Turning it off again (sudo blackbranch federation off) cuts outside servers off at once, but copies of messages already on their servers stay there. The server name never changes either way.

Next: Customizing

← Install