Self-hosting a RIM server
deploy/compose.yml runs one RIM server on one domain: rim-server with RIM_ROLE=both (it
hosts workspaces and is its users' relay), PostgreSQL 17, the web client, and Caddy terminating
TLS. Caddy sends /api (with /api/ws), /.well-known/… and /s2s/… to rim-server and every
other path to the web client, so the client and the API share one origin, unless the web client
gets a domain of its own ("The web client on its own domain"). The health probes stay inside
the compose network. Both Caddyfiles send Strict-Transport-Security: max-age=31536000 on the
https sites, without includeSubDomains or preload: a browser that has reached the site once
keeps using https for a year, and the header says nothing about other names. Take it out of the
Caddyfile only if the domain must go back to plain http.
A public relay is the same file with deploy/compose.relay.yml on top;
Run your own relay covers it.
Everything marked FILL is the operator's choice, recorded here once made.
Before the first start #
A Linux host with Docker (Compose v2.20 or later), ports 80 and 443 reachable from the internet, and DNS
A/AAAArecords of your domain pointing at it. Caddy gets the certificate from Let's Encrypt on the first request.This repository at the release you run. The compose files, the Caddyfile and the backup scripts come from the checkout; the images are pulled:
git clone https://github.com/rim-platform/rim-server.git cd rim-server git checkout v<version>The compose files run
ghcr.io/rim-platform/rim-serveratRIM_VERSIONfromdeploy/.env; set it to the same<version>. Left unset it islatest, which moves with every release. The web client,ghcr.io/rim-platform/rim-web, is rim-ui's release and is versioned on its own: setRIM_WEB_VERSIONto a rim-ui release, such as its latest (unset, it isRIM_VERSION). To build both images on the host instead, check out rim-ui next to this repository and add-f deploy/compose.dev.ymlto every compose command (the alias below) withup --build.deploy/.envfrom the example, filled in:cp deploy/.env.example deploy/.env chmod 600 deploy/.env sed -i "s|^POSTGRES_PASSWORD=.*|POSTGRES_PASSWORD=$(openssl rand -base64 32 | tr -d '/+=')|" deploy/.env $EDITOR deploy/.env # RIM_VERSION, RIM_WEB_VERSION, RIM_DOMAIN, and SMTP for invitesEvery variable the compose files read is in
.env.examplewith what it does. WithoutPOSTGRES_PASSWORDorRIM_DOMAINevery compose command stops and names the variable.Check the configuration:
alias dc='docker compose -f deploy/compose.yml' dc config >/dev/null && echo ok
The commands below use that alias, from the repository root.
Verify the images #
The release workflows sign every image with cosign keyless. The certificate names the repository's release workflow and the tag it ran for, so an image built or signed anywhere else does not verify. Before the first start and after every upgrade:
v=0.0.1 # your RIM_VERSION
w=0.0.1 # your RIM_WEB_VERSION
dc pull
cosign verify ghcr.io/rim-platform/rim-server:$v \
--certificate-identity https://github.com/rim-platform/rim-server/.github/workflows/release.yaml@refs/tags/v$v \
--certificate-oidc-issuer https://token.actions.githubusercontent.com
cosign verify ghcr.io/rim-platform/rim-imagecheck:$v \
--certificate-identity https://github.com/rim-platform/rim-server/.github/workflows/release.yaml@refs/tags/v$v \
--certificate-oidc-issuer https://token.actions.githubusercontent.com
cosign verify ghcr.io/rim-platform/rim-web:$w \
--certificate-identity https://github.com/rim-platform/rim-ui/.github/workflows/release.yaml@refs/tags/v$w \
--certificate-oidc-issuer https://token.actions.githubusercontent.com
cosign prints the digest it verified, which is also in the GitHub release notes. Setting
RIM_SERVER_IMAGE, RIM_IMAGECHECK_IMAGE and RIM_WEB_IMAGE in deploy/.env to
…@sha256:<digest> makes compose run exactly those images. Each release also carries the image's SBOM (SPDX JSON), attested to the
image's digest as a GitHub attestation: gh attestation verify oci://<image>@<digest> --repo <the image's repository> --predicate-type https://spdx.dev/Document/v2.3 checks it.
The web client's endpoint #
The web client finds the API through VITE_GRAPHQL_ENDPOINT, baked in when its image is built.
The published image is built with /api, and deploy/compose.dev.yml passes
RIM_WEB_GRAPHQL_ENDPOINT, default /api: the client resolves it against the page's own
address, so one image serves any domain and needs no CORS. The image's
content security policy allows connect-src 'self', which covers the API and its WebSocket on
that origin; the browser console notes that it ignores the extra /api source the image adds.
https://<your domain>/api gives the same result without that note and ties the image to the
domain.
Browsers send an Origin header with the client's requests even on one origin. The server
accepts its own origin without configuration: that of RIM_PUBLIC_BASE_URL when set, else the
scheme and Host the request arrived with (X-Forwarded-Proto and X-Forwarded-Host count
only with RIM_TRUST_FORWARDED_HEADERS=true). Any other origin gets 400 Origin is not allowed, with two exceptions: the packaged desktop app's origins (tauri://localhost on macOS
and Linux, http://tauri.localhost on Windows), which no web page can carry, and one extra
origin named by RIM_CORS_ALLOWED_ORIGIN, such as a client served from another domain or the
desktop development app at http://localhost:1420. Left out of deploy/.env there is none, or
the web domain's origin when RIM_WEB_DOMAIN is set (next section). The desktop app on
Windows stays signed in only to a server on HTTPS whose cookies are Secure, since its requests
are cross-site and need SameSite=None cookies (docs/api.md, "The session cookie"); the
shipped compose deploy sets RIM_FORCE_SECURE_COOKIES: "true" in deploy/compose.yml.
The web client on its own domain #
RIM_WEB_DOMAIN in deploy/.env serves the web client on a second domain, such as
chat.example.org next to RIM_DOMAIN=rim.example.org; its DNS records point at the same host.
RIM_DOMAIN stays the server's name: RIM_PUBLIC_BASE_URL follows it, apps sign in to it,
other servers reach it, and the discovery document names it. deploy/Caddyfile then answers
for both names:
- on the web domain,
/api(with/api/ws) and/.well-known/rim-servergo to rim-server and every other path to the web client, so the page calls the API on its own origin and its content security policy,connect-src 'self', holds; server-to-server paths are not served there; - on
RIM_DOMAIN, the API, discovery and server-to-server paths go to rim-server as before, and every other path is redirected (302) to the web domain with its path and query, so the invite and owner claim links the server builds onRIM_PUBLIC_BASE_URLopen the web client.
The compose file derives two server settings from it. RIM_CORS_ALLOWED_ORIGIN becomes
https://<RIM_WEB_DOMAIN>, since the browser sends that Origin with the client's requests,
WebSocket included. RIM_KEY_LOGIN_AUDIENCES becomes <RIM_DOMAIN>,<RIM_WEB_DOMAIN>, since the
web client names the host of the page in its key login proofs, while the desktop app names
RIM_DOMAIN; both are this server, so a proof still cannot be replayed on another one. Setting
either variable in deploy/.env replaces the derived value. The session cookies are set by the
origin that answers the login, the web domain for the web client, with no Domain attribute.
First start #
dc up -d
dc logs -f rim
The migrate service applies the migrations and exits; the server starts after it. dc ps
shows rim as healthy once /readyz passes.
Every service but caddy-init runs as an unprivileged user (PostgreSQL as postgres,
rim-server and migrate as rim, the web client as nginx, Caddy as nobody). None can gain
privileges, and each has a read-only root filesystem, so the data lives only on the named
volumes. Only Caddy holds a capability, NET_BIND_SERVICE, which the binary in its image needs
to start and which allows nothing more inside a container. caddy-init runs before Caddy at
every start: as root, able only to read directories and change owners, it gives caddy_data
and caddy_config to nobody and exits, so volumes an earlier root Caddy wrote keep working.
dc cp refuses a read-only container; pass a file in with
dc exec -T rim sh -c 'cat > /tmp/<file>' < <file>.
The server recovery key #
On its first start the server creates its key and writes the recovery key to
/data/server-recovery-key.txt, and it logs a warning at every start until the file is gone.
The recovery key replaces a lost or stolen server key; whoever holds it can make any key this
server's, so it never stays on the host:
dc exec rim cat /data/server-recovery-key.txt
# store the line offline: a password manager and a printed copy, held by two people
dc exec rim rm /data/server-recovery-key.txt
dc exec rim /app/rim-server server-key show names the recovery key's public half, so a copy can
be checked without using it. Backups never include the file (below). docs/server-identity.md
has the key commands, rotation and recovery.
The first account #
Signups are invite-only by default. Issue a single-use link for your own account; it works for
7 days (--expires-in-days changes that):
dc exec rim /app/rim-server invite create --public-url https://rim.example.org
--email you@example.org binds the link to that address: the account that signs up with it
gets that address. It does not keep others out: whoever holds the link can sign up with it and
get the address. Hand the link only to the person it is for.
Open the link it prints (https://rim.example.org/join/…) and sign up. For other people, a link
for up to 50 signups that lasts up to 30 days:
dc exec rim /app/rim-server invite create --max-uses 10 --expires-in-days 7 --public-url https://rim.example.org
dc exec rim /app/rim-server invite list
dc exec rim /app/rim-server invite revoke <id>
The owner of a workspace can also invite from the app. RIM_OPEN_REGISTRATION=true lets
anyone sign up, rate-limited per address; RIM_REGISTRATION_POW_BITS asks a proof-of-work of
signups without an invite.
Check it answers #
dc exec rim curl -fsS http://localhost:8080/readyz; echo
curl -s https://rim.example.org/.well-known/rim-server | head -c 300; echo
curl -sI https://rim.example.org/ | head -n 1 # the web client (302 with RIM_WEB_DOMAIN)
dc exec rim /app/rim-server --version
Updates #
Take a backup first (below): migrations only go forward, so a backup is the way back.
deploy/backup.sh
git fetch --tags && git checkout v<version>
$EDITOR deploy/.env # RIM_VERSION=<version>
dc pull # then verify them, as above
dc up -d
dc logs -f rim
deploy/upgrade.sh <version>, run after the checkout, does these steps with the signature
check and rolls back when the new version does not come up; the web client stays at its
RIM_WEB_VERSION. up runs migrate before it starts the new server. To run the migrations
alone, dc run --rm migrate. Rolling the image back leaves the migrations in place: the
previous release runs on them, started with dc up -d --no-deps rim imagecheck, and anything
further back is the backup taken before the update. The web client moves on its own: a new
RIM_WEB_VERSION, then dc pull web && dc up -d --no-deps web. docs/operations/upgrade.md
has the whole procedure, what to read in CHANGELOG.md first, the rollback and the web client.
Backups #
deploy/backup.sh writes one archive, rim-backup-<project>-<UTC time>.tar, under
RIM_BACKUP_DIR (default ./backups, which Git ignores). It holds:
| File | What |
|---|---|
rim.dump |
pg_dump -Fc of the database, checked to read back |
rim-data.tgz |
the rim_data volume: server key, franking keys, the link key (link-key.json), the password key (password-key.json), uploads, the audit files and audit exports |
env |
deploy/.env |
MANIFEST, SHA256SUMS |
project, time, server version, checksums |
The recovery key file is never in it; the script warns while it is still on the host. The database and the data volume are one set: the server key file must match the key log in the database, and the server refuses to start on a mixed set. Never restore one without the other. The password key belongs to the same set: the server refuses to start when it is missing while the database holds account passwords, and without it every account resets its password with its recovery phrase.
With RIM_BACKUP_AGE_RECIPIENT set (an age1… recipient or a file of recipients), the archive
is encrypted with age to ….tar.age and nothing unencrypted is
left on disk. Keep the identity that decrypts it off the host, with the recovery key's holders.
deploy/backup.sh
COMPOSE_FILE=deploy/compose.yml:deploy/compose.relay.yml deploy/backup.sh # a relay
The scripts read COMPOSE_FILE and COMPOSE_PROJECT_NAME the way docker compose does,
RIM_ENV_FILE for another env file, and the RIM_BACKUP_* settings from the environment or
deploy/.env.
How often. Nightly, and before every update or key rotation. A cron entry on the host:
15 3 * * * cd /srv/rim-server && deploy/backup.sh >>/var/log/rim-backup.log 2>&1
How long. With RIM_BACKUP_KEEP_DAYS set, each backup that succeeded deletes this
deployment's archives in RIM_BACKUP_DIR older than that many days; unset, every archive is
kept. Archives hold the audit files, and with them IP addresses, so keep them no longer than you
keep those.
Knowing it ran. With RIM_BACKUP_HEARTBEAT_URL set to an https URL, each backup that
succeeded fetches it at the end. Point it at a check that expects one ping a day, such as a
healthchecks.io check, and a night without a backup raises an alert. A failed ping is logged as a
warning and the backup still succeeds; a URL that is not https stops the script before it starts.
Where copies go. Off the host, encrypted: FILL the destination (object storage, another machine) and how long copies are kept. The archive holds the server's private key and every user's data; treat it like the host itself.
Restore #
deploy/restore.sh restores an archive into a stopped stack: it drops and recreates the
database from the dump, empties the data volume and refills it, starts the stack and waits for
/readyz. It asks for the project name before it replaces anything (RIM_RESTORE_YES=1 skips
that).
dc stop rim
deploy/restore.sh backups/rim-backup-rim-20261010T031500Z.tar
RIM_BACKUP_AGE_IDENTITY=~/rim-backup.key deploy/restore.sh backups/….tar.age
On a new host, check out the repositories, take deploy/.env from the archive's env file, build
or pull the images, and run the same command. A newer image applies its migrations to the
restored database when it starts.
The restore drill #
A backup is good once it has been restored. deploy/restore-drill.sh restores the newest archive
(or the one given) into a throwaway project, rim-drill, waits for /readyz, prints the server
key and the row counts of a few tables, and removes the project and its volumes. The drill's
server has server-to-server traffic and mail off and publishes no port, so it never speaks for the
real one; it runs next to the live stack on the same host.
deploy/restore-drill.sh
deploy/restore-drill.sh backups/rim-backup-rim-20261010T031500Z.tar
Run it after the first backup, every quarter, and after changing the backup setup. Compare the
server id and key seq with dc exec rim /app/rim-server server-key show and the row counts with
production's. Record each drill: FILL where.
Monitoring #
Probes. rim-server answers
/healthz(200 while the process runs) and/readyz(200 when the database answers, no migration is pending and the key files are readable, else 503 naming the failing checks) on its own port, without a session. They are for Docker and the compose network: therimservice's healthcheck uses/readyz, and Caddy answers both paths with 404. From the host:dc ps # rim, postgres and web: healthy dc exec rim curl -fsS http://localhost:8080/readyz; echo dc exec rim curl -fsS http://localhost:8080/healthz; echoAn outside uptime check watches the public origin instead, for example
https://<domain>/.well-known/rim-serverand the web client's/.Metrics. Uncomment
RIM_METRICS_ADDR: 0.0.0.0:9090in therimservice and run Prometheus in a container on the compose project'sinternalnetwork, scrapingrim:9090. Never publish the port or route it through Caddy. Or add-f deploy/compose.monitoring.yml: it turns the listener on and forwards the metrics, a/readyzprobe and the host's metrics to Grafana Cloud with Grafana Alloy;-f deploy/compose.monitoring-containers.ymlafter it adds each container's CPU and memory.docs/operations/metrics.mdlists the metrics, what the collector sends and what to alert on.Logs. JSON on stdout:
dc logs --since 1h rim. Audit events ("target":"audit") also go to the daily files/data/audit.<YYYY-MM-DD>.log, deleted afterRIM_AUDIT_LOG_RETENTION_DAYS(default 90);docs/operations/audit-retention.mdcovers them,RIM_AUDIT_RETENTION_DAYSfor the audit table andRIM_AUDIT_EXPORT_RETENTION_DAYSfor the rows it exports. Docker keeps about 100 MB of each service's output, in five files of 20 MB (theloggingoptions in the compose files), and deletes it with the container; ship it to your own log store to keep more.Background jobs.
docs/operations/background-jobs.mdlists what the server runs on a timer, how often, and the setting that changes it.Disk. The
postgres_dataandrim_datavolumes, andRIM_BACKUP_DIR.
Limits and blocking #
A server open to the internet can limit what one client sends: requests per address, mutations
per session, messages per user, and WebSocket connections and subscriptions. Every limit is off
until its RIM_RATE_* variable is set in deploy/.env (the "Request limits" block of
deploy/.env.example); docs/api.md ("Limits") says what clients see past each one. An
address or range that keeps misbehaving is blocked outright with
dc exec rim /app/rim-server ip block 203.0.113.0/24 --reason "scraping" --expires-in-days 30:
it gets 403 {"error":"blocked"} on every route but /healthz, server-to-server routes
included. Leave out --expires-in-days to block until ip unblock; ip list shows every block
with its expiry. A running server reads the list every 30 seconds, so a change applies within
that; each block and unblock is written to the audit log as ip.block or ip.unblock. Behind
Caddy the address is the client's, since RIM_TRUST_FORWARDED_HEADERS is on: the server reads
the first address in X-Forwarded-For, which Caddy replaces with the client's, and never
Forwarded, which the Caddyfiles drop. Behind another proxy it must replace X-Forwarded-For
(next sections), or one forged header unblocks a client.
Instance limits #
A public instance can also cap how much each person holds: workspaces per user, members and
channels per workspace, devices per account, DM requests to strangers per day, macros,
pipelines and plugins per workspace, invites per user per day, uses per invite and the bytes
of a message. Each is a RIM_LIMIT_* variable, off until set (the "Instance limits" block of
deploy/.env.example has values for a small test instance); past one a write is refused with
a message naming the cap, and clients read every cap from serverInfo.limits. Channels count
while unarchived, and a workspace holds at most five times the channel cap counting archived
ones. A member who is neither Owner nor Moderator holds at most a fifth of a
workspace's macro and pipeline caps, so no one member fills them, and loses theirs when kicked
or banned. A workspace handed over counts against its new owner's cap. Devices and DM
requests also follow the relay quotas RIM_RELAY_DEVICES_PER_USER and
RIM_RELAY_DM_REQUESTS_PER_DAY: the stricter number applies. A negative or non-numeric value,
or RIM_LIMIT_MESSAGE_BYTES above 65536, stops the server at boot. Two caps are on by default,
and 0 turns either off: RIM_LIMIT_PENDING_INVITES_PER_USER (50) bounds the invitations to
encrypted conversations one person holds, so nobody can be buried in them, and
RIM_LIMIT_INVITES_PER_USER_PER_DAY (50) bounds the workspace invites one person creates and
the invite emails they send in 24 hours, so nobody can use the server to mail strangers in bulk.
RIM_LIMIT_ACCOUNTS caps the accounts the server holds, for an instance that must not outgrow
its host or its budget. It counts the people who signed up here, those waiting out their
deletion grace period included, since they can still cancel; people from other servers held
here and purged accounts do not count, so a purge frees a place. At the cap every signup is
refused with a message that the server is full and that they can run their own server or sign
up on another one, an invite you created included: raise the cap to let someone in. Clients
read serverInfo.registrationFull and can say so before anyone tries. Signups check the cap one
at a time, so two at once never pass it. Lowering it below the accounts there are refuses new
signups only; nobody loses an account.
RIM_PROBATION_HOURS slows down accounts made to spam: for that many hours after its creation
an account cannot create a workspace, write a workspace's shared state, set a profile picture,
status or bio (it may set its display name), or send a DM request to someone it shares no
workspace with and does not know (a contact who lists it too, or someone either of them
accepted a DM request from; adding someone as a contact alone is not enough), and with RIM_RATE_PROBATION_MESSAGES_PER_MIN it sends messages at that lower rate. Existing accounts
are judged by their age, so turning it on does not hold back anyone older than the setting. The
default workspace ("A default workspace" below) is left out of the workspaces it shares, since
every new account joins it, and a DM in it meets probation like one in the direct space. The
instance operator is never on probation: the account that claims the default workspace with the
operator role, or one granted it with rim_server operator grant, can create workspaces and
message anyone from the moment it holds the role.
Profile pictures are re-encoded by the server: whatever is uploaded (PNG, JPEG, GIF or WebP, at
most 1 MiB and 4096 pixels a side) is stored as a 256×256 PNG of its first frame with no
metadata. Two limits per account are on by default, and 0 turns either off:
RIM_AVATAR_UPLOADS_PER_HOUR (5) and RIM_AVATAR_UPLOADS_PER_DAY (20). Every upload attempt
counts, a refused one too; removing a picture does not, and an instance operator is exempt. Past
either the upload is refused with 429 and Retry-After. The counts are kept in the server's
memory, so a restart starts them afresh. A profile with an abusive picture, name, status or bio
is cleared with rim_server principal clear-profile <principal-id> --reason <text>, and
--lock-days <n> keeps the account from setting them again for that many days
(docs/operations/relay-public.md, "An abusive profile"). It clears what this server shows;
another server keeps showing the display name in its copy of the person's signed profile card.
Optional features #
Attachments, link previews, email, custom emoji, workspace plugins, the AI command surface,
avatars, pinned plugin link fetches and the text art check can be switched off with RIM_FEATURES_DISABLED in deploy/.env;
docs/operations/features.md lists what each one covers and what clients see.
RIM_LINK_PREVIEW_CONCURRENCY (default 8) caps the link preview fetches running at once. A preview keeps at most 300 characters of title, 1,000 of description and 100 of site name,
drops an image address over 2,048 characters, and a message fetches each distinct address once.
Outgoing requests ignore proxy environment variables.
Content check #
Each check can be switched off on its own with RIM_FEATURES_DISABLED (avatar_check,
text_art_check), or both by leaving RIM_AVATAR_CHECK_URL empty; the imagecheck service can
then be removed from the stack.
Profile pictures #
deploy/compose.yml runs imagecheck next to the server: a small service, built from
imagecheck/ in this repository and published as ghcr.io/rim-platform/rim-imagecheck, that
scores every uploaded profile picture for sexual content, gore and violence, each from 0 to 1.
It runs two models on the CPU, a trained nsfw classifier and CLIP, and takes about a tenth of a
second a picture; with the text art model (below) it holds about 825 MiB of memory (its limit is
1536 MiB and 2 CPUs). It is on the internal network only and reaches nothing;
imagecheck/README.md describes the models, their licences and the scores of ordinary
pictures.
The server holds the highest of the three scores against two thresholds:
| Setting | Default | At or above it |
|---|---|---|
RIM_AVATAR_CHECK_BLOCK |
0.85 | the upload is refused with 422 and nothing is stored |
RIM_AVATAR_CHECK_REPORT |
0.60 | the picture is stored and an abuse report is filed for the operators |
Both are in (0, 1], and the report threshold is at most the block one, or the server stops at boot. Below both the picture is stored. Nobody approves a picture before it is shown.
RIM_AVATAR_CHECK_URL is where the server reaches the service, http://imagecheck:8090 in
deploy/compose.yml. The server does not wait for the service at start: while it is down,
picture uploads answer 503 and everything else works. To run without it, set
RIM_AVATAR_CHECK_URL= (empty) in deploy/.env and leave the imagecheck service stopped;
pictures are then stored unchecked, and the server logs a warning saying so at every start.
Text art #
The same service scores messages that look like text art: drawings made of braille, block,
box-drawing or ASCII characters (docs/messaging.md, "Flagged messages", says which messages
count). The server sends the message's art block (the picture inside the text, without the
words around it) and nothing else, only for messages it can read in a workspace: never an
encrypted message and never a DM or group of the direct space. The block goes to
RIM_AVATAR_CHECK_URL over the internal network and leaves the host no further; the service
keeps nothing.
| Setting | Default | At or above it |
|---|---|---|
RIM_TEXT_ART_CHECK_FLAG |
0.60 | the message is flagged: clients cover it, the workspace's Owner and Moderators get an automatic report and the operators an abuse report |
It is in (0, 1], or the server stops at boot. The check runs after the message is stored and
never delays or refuses it; at most two messages are scored at once, and one that waits more
than 30 seconds for its turn, or that the service cannot score, stays unflagged with a warning
in the log. An Owner or Moderator clears a flag with clearMessageFlag.
text_art_check in RIM_FEATURES_DISABLED turns the text check off and leaves the picture
check on. Without RIM_AVATAR_CHECK_URL both are off, and serverInfo.features shows
text_art_check as unavailable. The text model takes memory beside the picture models;
imagecheck/README.md, "Resources", has the numbers to size the service's limit by.
Notice and terms #
RIM_INSTANCE_NOTICE is a short text, at most 500 characters, that clients show people on
your server, such as who runs it and how to reach you. Once your server has terms of service,
every signup has to accept them and the server records on the account when it did and which
URL it accepted. The terms come from one of two settings, never both (both set stops the
server at boot):
RIM_TERMS_FILE, a Markdown file the server reads at start and serves as a page athttps://<your domain>/api/terms.compose.ymlmountsdeploy/terms.mdat/config/terms.md; that file is the public RIM server's terms, so rewrite it for your server, then setRIM_TERMS_FILE=/config/terms.md. The page shows headings, paragraphs, lists, bold and italic text, code and links (https, http and mailto); any HTML in the file is shown as text, and<!-- -->comments are left out. The terms URL carries a short hash of the file (/api/terms?v=…), so after an edit anddc restart rimnew signups accept the new version and each account records which one it accepted. A missing, unreadable, empty or larger than 64 KiB file, or aFILL:placeholder left outside a comment, stops the server at boot.RIM_TERMS_URL, the address of terms you host elsewhere, an absolute http(s) URL.
RIM_ABUSE_CONTACT is where to report abuse on your server: an email address or an https URL.
The server publishes it in its signed descriptor, so other servers can find it, and clients
show it. Anything else stops the server at boot.
RIM_MINIMUM_AGE (13 to 21) asks every signup to confirm that the person has reached that
age: clients show "I am at least 16" beside the terms, and a signup without the confirmation
is refused. The age is self-declared. Nothing checks it and the account records only the age it
confirmed, next to its acceptance of the terms.
All of these are commented out in deploy/.env.example and reach the rim service when set;
clients read them from serverInfo. A notice over 500 characters or a terms URL that is not an
absolute http(s) URL stops the server at boot. Changing the terms does not ask existing
accounts to accept again.
RIM_RESERVED_NAMES (commented out in deploy/.env.example) lists usernames and display names
that signups and profile edits refuse, ignoring case, invisible characters and lookalike letters
from other scripts (Cyrillic А for A), so nobody can pose as your maintainers; a person from
another server whose profile card names one is shown by their username instead. The signup
through the owner claim link of a defined default workspace may take a reserved name, so the
owner's name can be listed before the first start. Any other maintainer's name is added once
their account exists, since it refuses those names to new signups too.
Legal duties of an operator #
Running a server that strangers can sign up on makes you a hosting provider for what they post, with duties that a server for your own team or friends mostly does not have. This is not legal advice; the rules depend on where you and your server are.
- Keep signups invite-only unless you mean otherwise. It is the default: nobody signs up
without a link you issued, unless
RIM_OPEN_REGISTRATIONorRIM_REGISTRATION_POW_BITSis set. Opening registration is what turns your server into a public service. - Be reachable for abuse reports. Set
RIM_ABUSE_CONTACTand read what arrives there, as well as the reports people file from the app; "Abuse policy" indocs/operations/relay-public.mdhas a policy text to start from. In the European Union the Digital Services Act expects a hosting provider to have a point of contact and to act on notices of illegal content. - Act on illegal content. Remove it and block the account once you know of it
(
rim-server principal block,rim-server abuse-reports, or instance moderation in the app,docs/api.md). Child sexual abuse material is removed at once and reported to the police; keep only what the police ask you to keep. - Know what you can see. Workspace channels are stored readable on your server; direct messages and encrypted groups are not, so you cannot moderate their content, only the accounts and the reports people send you.
- Publish terms and, if your law asks for one, a minimum age.
RIM_TERMS_FILEandRIM_MINIMUM_AGE("Notice and terms" above). Under the GDPR the age below which a parent has to consent to a child's use of such a service is set by each country, between 13 and 16. - RIM never asks anyone for an ID. RIM has no identity check and collects no ID documents; the minimum age is a statement the person makes, and the account records only that they made it.
A default workspace #
A server may name one workspace that every new account joins as a Member, whichever way it
signs up: open, proof-of-work, with an instance invite or a workspace invite, with a key or a
password. The account joins as soon as it exists and gets the workspace's public channels like
any new member, so people land where others already are instead of in an empty direct space.
serverInfo.defaultWorkspace names the workspace, so a client can open it after a signup.
Without one, nothing changes: a new account joins only the workspace its invite names. Sharing
the default workspace makes nobody known to a new account in probation (RIM_PROBATION_HOURS):
it still sends no DM request to someone it shares no other workspace with.
There are two ways to name it: describe it in a file, or point at a workspace made in the app. Setting both stops the server at boot.
From a definition file #
RIM_DEFAULT_WORKSPACE_FILE names a JSON file that describes the workspace. compose.yml
mounts deploy/default-workspace.json read-only at /config/default-workspace.json; set the
variable to that path in deploy/.env (a relay that hosts a workspace does the same,
deploy/README.md). The committed file is the project's own workspace on the public relay; edit
it for yours:
{
"name": "RIM",
"claimGrantsOperator": true,
"dm": { "outsideFloor": "REQUESTS", "memberDefault": "REQUESTS" },
"channels": [
{ "name": "general", "topic": "Anything about RIM" },
{ "name": "announcements", "topic": "Releases and news from the project", "posting": "moderators" }
]
}
name(required): the workspace's name, at most 128 characters.claimGrantsOperator(defaultfalse): the account that claims the workspace also becomes an instance operator, asrim-server operator grantwould make it.dm(optional): the workspace's DM policy, assetWorkspaceDmPolicytakes it:outsideFloorisNONE,REQUESTSorCLOSED,memberDefaultisDIRECTorREQUESTS. Everyone on the server shares the default workspace, so withDIRECTevery account's first DM or group to anyone else here arrives at once and meets no request limit;REQUESTS, as in the committed file, holds it in the recipient's request inbox until they accept it, and each member can still chooseDIRECTfor themselves (setMyWorkspaceDmSetting).channels(optional): each with aname(at most 100 characters, unique in the file), an optionaltopic(at most 512 characters),private(defaultfalse), an optionalpostingand an optionalpostingAllowsThreads.postingis who may post in the channel, assetChannelPostingsets it:"everyone"or"moderators"(the Owner and Moderators only, as forannouncementsin the committed file).postingAllowsThreads(defaulttrue, only together withposting) says whether, under"moderators", everyone else may still react and reply in threads. Withoutpostingthe channel's setting stays as it is.
The server checks the file at every start; a field it does not take, a missing name, a value out of range or a file it cannot read stops it at boot with a message naming the field. The owner is not in the file: it is claimed.
The claim. While nobody has claimed the workspace, each start issues a single-use owner
claim link, an instance invite valid for 30 days, and writes it to owner-claim.txt in the data
directory (/data/owner-claim.txt in the compose stack), readable by its owner only. The log says
that a claim is waiting and names the file, never the link. Each start revokes the previous link,
so a lost or expired link is a restart. Read it and open it in the app:
dc exec rim cat /data/owner-claim.txt
The account that signs up through the link, with a key or a password, creates the workspace in
the same step: the workspace with that account as its Owner, the channels with their topics and
posting policies, the DM policy, and the instance operator role when claimGrantsOperator is set. Every local account
that already exists joins it as a Member. The link is then used up and the file deleted; nothing
needs editing and nothing restarts. Only a new signup claims: an account that already exists
cannot, and nobody can claim by registering a name first, since only someone who can read the
data directory has the link. The link is an invite, so it works on an invite-only server and
stands in for the proof-of-work in proof-of-work mode; a server with RIM_OPEN_REGISTRATION,
whose signups take no invite, refuses to start until the workspace is claimed.
Every later start applies the file to the claimed workspace again: it renames the workspace when the name changed, creates the channels missing by name (with no members; new accounts join the public ones), sets the topics and posting policies the file gives and the DM policy. It never deletes a channel or a member, never changes a channel's privacy and never moves ownership (the Owner transfers it in the app). A channel renamed in the file is a new channel: rename it in the app first, then in the file. A channel or topic made in the app and left out of the file stays as it is. A channel of a file's name that someone other than the Owner or a Moderator created is left alone, topic included, and the log names it: give the file's channel another name. When the claimed workspace is deleted, the next start offers a new claim. Unsetting the variable stops the default workspace (signups join nothing) and revokes a waiting claim link; the workspace itself stays.
A workspace made in the app #
RIM_DEFAULT_WORKSPACE (commented out in deploy/.env.example) names a workspace on this server
by its id. Create the workspace in the app, look its id up, set it in deploy/.env and run
dc up -d:
dc exec -T postgres psql -U rim -d rim -c "SELECT id, name FROM server WHERE kind = 'workspace'"
A value that is not a workspace id, a workspace that does not exist on this server, and the
direct space each stop the server at boot. Accounts that existed before may join through joinDefaultWorkspace. A workspace deleted
while the server runs stops the joins until the setting changes, and
the next start refuses its id.
Either way #
An account already in the workspace, or banned from it, is left as it is at signup.
An unban restores a local account to the current default workspace as Member with its public
channels. After a temporary ban expires, joinDefaultWorkspace lets the account rejoin. A
kicked account can also use this route; use a ban when rejoining must remain blocked. In the default
workspace only the Owner and Moderators create channels, add people to channels and change
their topics, and only their @channel and @here notify everyone. A group there is started
like a DM with each of its members, following their DM settings and the request inbox, with at
most 50 members. Macros and pipelines there follow each member's share of
RIM_LIMIT_MACROS_PER_WORKSPACE and RIM_LIMIT_PIPELINES_PER_WORKSPACE but no per-workspace
cap, so a few accounts cannot fill it for everyone, and an account in probation creates none.
RIM_LIMIT_MEMBERS_PER_WORKSPACE does not keep a new account out of the default workspace, but
an invite to it still follows the cap. The workspace's channels are ordinary plaintext channels;
DMs and encrypted groups are untouched, and other servers see an ordinary membership.
Handles #
Everyone here has a handle, @<username>:<domain>, which other servers and their apps show
for them and which people type to mention or search for them. Usernames are 3 to 32 letters,
digits, _ and -, stored in lowercase: Kuba signs up as kuba, and sign-in and search
accept any case. The domain is RIM_HANDLE_DOMAIN, commented out in deploy/.env.example: by
default the host of RIM_PUBLIC_BASE_URL (rim.example.org gives @kuba:rim.example.org),
and the server refuses to start when it is not a DNS name. Handles may use a shorter domain
than the server's, say example.org for a server at rim.example.org, when
https://example.org/.well-known/rim-server serves {"delegate": "https://rim.example.org"};
docs/server-identity.md, "Handles and delegation", has the details. Choose the domain before
people join: changing it later changes every handle here (keys, contacts and memberships stay).
RIM_DM_INBOUND, RIM_DM_OUTBOUND and RIM_DM_PARTNERS (commented out in
deploy/.env.example) set floors for every account: by default a stranger's first message is a
request the recipient accepts, and people here may start DMs with anyone. A company closes its
server with none, or opens it to named partner servers with partners
(docs/operations/closed-company-server.md). Workspace owners and each person tighten further
in the app ("Who May Start A DM" in docs/messaging.md). A value the server does not take stops
it at boot.
Deleted accounts #
People delete their own account from the client. The account is purged once a grace period
ends, RIM_ACCOUNT_DELETION_GRACE_DAYS days after the request (default 14, 0 to 30; 0 purges at
the next hourly run; commented out in deploy/.env.example); until then the person can cancel.
The purge removes the account's sessions, devices and keys, memberships, plaintext messages with
their files, every file in its avatar directory (avatars/<user id>/ under the uploads), settings
and personal automations, and deletes the workspaces where it was the only member. What remains is a tombstone row with the same id, named deleted- and the
start of the id, shown as "Deleted account", with no email, password or key: it cannot sign in,
shows in no member list or search, and stays the author of the account's encrypted messages
(their ciphertext is kept), of messages others replied to (shown as deleted), and of the
workspace pipelines it created. It keeps the account's key identity id, so its revoked devices
still leave encrypted groups, and the same key identity cannot sign up on this server again.
Audit rows are kept until audit retention removes them, and the
purge writes account.purged to the audit log. dc exec rim /app/rim-server account purge --dry-run shows what the next run would remove; without --dry-run it runs the purge now.
Another proxy #
Caddy is an example. Any TLS proxy works if it:
- sends
/api(with/api/wsas a WebSocket upgrade),/.well-known/…and/s2s/…torim:8080unchanged, and the rest toweb:80; with a web domain, it sends that domain's/apiand/.well-known/rim-servertorim:8080and the rest toweb:80, and redirects the server domain's other paths there; - keeps
/healthzand/readyzoff the public side; - accepts bodies up to 32 MiB;
- sets
X-Forwarded-Foritself, replacing what the client sent: the server takes the client's address from its first entry and never readsForwarded; - drops
Forwarded, as the Caddyfiles do withheader_up -Forwarded; - keeps its access log private, or leaves
/api/hooks/*out of it (see below); - is the only way in.
deploy/README.md has an nginx example for the relay's paths.
Access logs hold webhook URLs. The token of an incoming webhook is in its URL path
(POST /api/hooks/<token>, bots.md), and anyone holding that URL can post to its channel as its bot.
rim-server writes the token to no log or metric, but a proxy's access log records paths. The
deploy/Caddyfile here turns on no access log. If you add one, or run another proxy that keeps one,
keep it as private as the database, or leave /api/hooks/* out of it. A URL found in a log is revoked
and replaced.