Run your own relay
Run the relay on a server of your own: what you give up, Docker or a single program, TLS, TURN for calls, and its settings.
Uplink's relay is one small program. Anyone can run it on a server of their own and point their app at it under Settings › Routes › Relay server. This page is for whoever runs that server: what you get and what you give up, how to run it with Docker or as a single program, calls through your own TURN server, a link helper, and how to check it and keep it updated.
What you get, and what you don't
Relays can pass sealed packets to each other, so friends can be on different relays. That is the keeper's choice on each relay, and it is off unless switched on (below). Everything else a relay keeps is still that relay's own.
| What | On a relay of your own |
|---|---|
| Friends by username: requests, messages, reactions, edits, read marks | Yes, between people on your relay. With people on another relay too, where both relays talk to each other: add them as @maya@their.relay. |
| Circles and spaces | Only between people on the same relay. A link made on your relay names it at its end (…@relay.example.com): opened by someone on another relay, the app says which relay the circle is on instead of joining an empty room there, and a browser guest opening a space's link is connected to the relay it names. |
| Calls | Only between people on the same relay: a call is a room on one relay. The app says so instead of ringing a friend on another relay. Calls that can't go straight between two devices need your own TURN server. |
| Who is online, away, last seen | Not shown for a friend on another relay. |
| Your account (username and password, the sealed backup) | Kept on the relay you made it on. Signing in on a new device works only with that device on the same relay, and the sign-in screen says which relay it asks. An app moved to a relay that doesn't hold its account keeps everything and offers List this device again, which puts the account on that relay from the device. |
| Your username | Kept on each relay apart. @maya on yours and @maya@relay.example can be two people. When the app moves to another relay your username is claimed there too where it is free; where someone else holds it, your profile asks you to choose one for that relay. The one on the relay you left is yours again when you go back. |
Add-me links (gogho.st/add/…) | A link made on your relay names it after the key (#KEY@relay.example.com). Whoever opens it is asked for on that relay, from whichever relay they use; a link that names none is someone on gogho.st. The link's key makes sure it is only ever the person who shared it. |
Circle invite words (gogho.st/c/…) | Kept on each relay apart. A word made on your relay works typed into Join a circle by people on your relay; the gogho.st page only knows gogho.st's words. |
| Files spaces | Kept on your relay's disk, for people on your relay. |
| Texts (SMS), encrypted ones included | Unchanged. They go over the phone network, not through any relay. |
| The Marketplace | Always Uplink's, read from gogho.st whatever relay you use. Submitting a plugin needs a username claimed on gogho.st, so it doesn't work from your relay. |
| Verifying your number; linking Discord, X, Telegram | Off unless you set up your own Twilio Verify service and your own apps with those networks. |
| Waking a closed iPhone | Not possible. It needs Apple's push key for the app, which only the app's publisher holds. An iPhone gets what was held for it the next time the app is opened. |
| Share feedback | Goes to your relay where you set up a board for it; where you didn't, the app sends it to gogho.st instead, since it is about the app. |
| A computer paired to the phone | Messages go through the phone, so through your relay, and the computer's own connection for spaces goes to the relay the phone uses. |
| Souls | Counted by each relay apart. The Souls page says whose count it shows; bug bounties are given on gogho.st. |
| App updates, these docs, the website | From gogho.st, as before. |
Not done yet: circles, spaces and calls across relays (the app uses one relay at a time, and an invite to a circle elsewhere says which relay to use first); who is online across relays; and signing in by username on another relay than the account's own, until a device that holds the account lists itself there.
What it is
One program on one port (8787 unless told otherwise), speaking plain HTTP and WebSockets. It has no dependencies beyond Dart's own library. You put a web server in front of it for TLS.
| Path | What |
|---|---|
/hub (WebSocket) | The hub: apps sign in with their key, find each other and pass sealed packets. It holds packets for people who are away (in memory, 96 MB at most), and keeps presence, rooms for circles, spaces and calls, usernames, sealed account backups and invite words. |
/relay/<channel> (WebSocket) | A phone and its paired computer when they're on different networks. |
/files/… | Files spaces' sealed files, on disk. |
/word/<hash> | A circle's invite word. |
/link/… | The pages a network sign-in comes back to, only with those networks set up. |
/market/… | A Marketplace. The apps never read yours; the sample settings close it. |
/app/… | The app in a browser, only where you give it a folder to serve. |
| anything else | Ghost Messaging relay as plain text: a quick check that it is up. |
It writes only under its data folder (--data): pairings, usernames, sealed account backups, Files, invites and invite words. Back that folder up if you care about any of it. Nothing it holds can be read without the apps' keys, but which installs talk to which is visible to whoever runs it, as with any server.
What you need
- A server with a domain name pointed at it.
- Ports 80 and 443 open.
- A few hundred MB of memory.
- The source: github.com/InfamousVague/ghost-messaging. Every sample file named on this page is in
relay/deploy/, and the image is built fromrelay/Dockerfile.
The examples use relay.example.com. Put your own domain in its place.
With Docker Compose
This runs the relay with Caddy in front of it. Caddy gets and renews the certificate by itself once your domain's DNS points at the server. It needs Docker Compose 2.24 or later.
cd relay/deploy
cp relay.env.example relay.env # and edit: nothing in it is required
cp Caddyfile.example Caddyfile # put your domain in place of relay.example.com
docker compose up -d
curl https://relay.example.com/ # Ghost Messaging relay
The relay isn't published on any port of its own; only Caddy reaches it. What it keeps is in the relay-data volume.
Compose pulls the relay's image, which every release publishes for x64 and arm64 machines: ghcr.io/infamousvague/ghost-relay, tagged with the version and latest. The image alone, without Compose:
docker run -d --name ghost-relay --restart unless-stopped -p 127.0.0.1:8787:8787 \
-v ghost-relay-data:/data --env-file relay.env ghcr.io/infamousvague/ghost-relay:latest
To build it yourself instead, from the source's folder: docker build -t ghost-relay relay, and use ghost-relay in place of the published name.
It runs as an unprivileged user, in an image with nothing but the program, the C library and certificates. Put a web server in front of it for TLS, as in the next section.
As a single program, with systemd
Each release publishes the program for Linux on x64 and arm64, with the service file beside it, on the releases page (relay- and the version). Download the one for your machine, check it, and install it as a service:
V=0.12.42 A=x64 # or arm64
curl -LO https://github.com/InfamousVague/ghost-messaging/releases/download/relay-$V/ghost-relay-$V-linux-$A.tar.gz
curl -LO https://github.com/InfamousVague/ghost-messaging/releases/download/relay-$V/ghost-relay-$V-linux-$A.tar.gz.sha256
sha256sum -c ghost-relay-$V-linux-$A.tar.gz.sha256 && tar xzf ghost-relay-$V-linux-$A.tar.gz && cd ghost-relay-$V-linux-$A
sudo useradd --system --no-create-home --shell /usr/sbin/nologin ghost-relay
sudo install -d -m 755 /opt/ghost-relay && sudo install -m 755 ghost-relay /opt/ghost-relay/ghost-relay
sudo install -d -o ghost-relay -g ghost-relay -m 700 /var/lib/ghost-relay
sudo install -o root -g ghost-relay -m 640 relay.env /etc/ghost-relay.env
sudo cp deploy/ghost-relay.service /etc/systemd/system/
sudo systemctl daemon-reload && sudo systemctl enable --now ghost-relay
It listens on 127.0.0.1:8787 only, writes only to /var/lib/ghost-relay, and restarts if it stops. The settings file is optional: the service starts without one. To build the program yourself instead, with Dart 3.11 or later: dart compile exe bin/relay.dart -o ghost-relay in the source's relay folder.
Then put a web server in front of it for TLS:
- Caddy:
relay/deploy/Caddyfile.example, withrelay:8787changed to127.0.0.1:8787. - nginx:
relay/deploy/nginx.conf.example, with a certificate from certbot or similar.
Whichever you use, it must pass WebSockets on, let a 10 MiB request body through (Files' pieces are up to 8 MiB), and not cut an open WebSocket off after a minute. Keep it on the same machine as the relay, so the relay sees each person's own address.
The environment variables
relay/deploy/relay.env.example lists every variable the relay reads, grouped by what each switches on. None is required: with no file at all it runs the hub, pairings, Files and invite words with their defaults. One NAME=value a line, no quotes, no spaces. Some values are secrets, so keep the filled-in copy where only root or the relay's own user can read it.
The sample sets three things, and you should keep them:
| Variable | What it is |
|---|---|
GHOST_PUBLIC_URL | Your relay's https address, with no slash after. Its built-in default is not yours. |
GHOST_ADMIN_NAMES | Set empty. Its built-in default is someone else's username. |
GHOST_MARKET_ON | Set to 0, which closes the relay's own Marketplace. The apps never read yours. |
The rest are optional:
| Variable | What it switches on |
|---|---|
PORT | The port, where --port isn't given (8787). --host and --data are options on the command line, not variables. |
GHOST_HUB_NAMES | Every host name your relay is reached at, commas between. Sign-ins are then bound to the name the app dialled (below). |
GHOST_HUB_KEEP_HELD | 1 keeps what is held for people who are away on the server's disk too, still sealed, so a restart doesn't lose it. |
GHOST_WIRE_MB, GHOST_WIRE_EACH_MB, GHOST_WIRE_STALL_S, GHOST_WIRE_IN_STALL_S | How much every connection may hold together (64 MB), how much may wait for one (8 MB) and for how long (10 seconds going out, 20 coming in) before it is ended. The defaults suit a relay with 300 MB; give more where it has more. |
GHOST_TURN_SECRET, GHOST_TURN_URLS, GHOST_TURN_TTL | Calls through your own TURN server. The secret and the addresses go together: both, or neither. |
GHOST_LINK_HELPERS | Where your link helpers are: https addresses, commas between, 4 at most. Without it devices make direct links only on one network. |
GHOST_FED, GHOST_PUBLIC_HUB, GHOST_FED_ALLOW, GHOST_FED_BLOCK | Talking to other relays: off (the default), open or list, your hub's own address, and the relays allowed or never linked with. |
GHOST_FED_PACKETS_A_MINUTE, GHOST_FED_BYTES_A_DAY, GHOST_FED_LOOKUPS_AN_HOUR | What one linked relay may send yours. |
GHOST_FED_PORTS, GHOST_FED_PLAIN | More ports other relays may be dialled at, and 1 to dial without TLS, which you want only between machines you run yourself. |
GHOST_FED_VIA, GHOST_FED_STANDING | For a relay with no address of its own: the public relay it stays linked to. And, on a public relay, which such relays may stay linked to it. |
GHOST_FILES_… | Files spaces' limits, each with a default. The defaults allow very large files: lower GHOST_FILES_TOTAL to fit your disk. |
GHOST_WEB_DIR, GHOST_APP_ORIGIN | The app in a browser: a folder holding the browser build, served under /app/ (the same as --web), or the address it is served from where that is one of its own. |
GHOST_TWILIO_SID, GHOST_TWILIO_TOKEN, GHOST_TWILIO_VERIFY, GHOST_TEXT_TO, GHOST_TEXTS_A_DAY | Verifying phone numbers by text, with your own Twilio Verify service. Without the first three nobody can verify a number on your relay. |
GHOST_DISCORD_ID, GHOST_DISCORD_SECRET, GHOST_X_ID, GHOST_X_SECRET, GHOST_TELEGRAM_BOT, GHOST_TELEGRAM_TOKEN, GHOST_GITHUB_TOKEN | Linking accounts in Settings › Me. Each needs your own app registered with that network. A network left empty is "not set up" in the app. |
GHOST_ADMIN_USER, GHOST_ADMIN_HASH | The admin page. Of little use on your relay: the app shows it only to one built-in username. |
GHOST_MARKET_… | The Marketplace's limits. Leave them alone with GHOST_MARKET_ON=0. |
GHOST_APNS_…, GHOST_NOTION_…, GHOST_BOUNTY_KEY | Only Uplink's own relay can use these. Leave them empty. |
The sample file says what each one is, with its default.
Sign-ins bound to your relay
Recommended. List every host name your relay is reached at, commas between, with a port only where it is not 443:
GHOST_HUB_NAMES=relay.example.com,www.relay.example.com
With them the hub asks apps to sign in bound to the name they dialled, and refuses a sign-in made for another relay. That stops a relay one of your people was pointed at from signing in to yours as them.
- An app that dialled a name you didn't list is refused, so list them all.
- Keep every listed name registered to you for as long as it is listed.
- Switch it on only once your people's apps are up to date. From an account's first sign-in of this kind, its older builds are refused and told to update.
Calls through your own TURN server
Calls go straight between the two devices where they can. Where they can't (two strict networks, some mobile networks), they need a TURN server to pass through. Without one on your relay such calls don't connect. The TURN server is coturn.
Install coturn
apt install coturn, or with the Compose file:docker compose --profile calls up -d.Its settings
Copy
relay/deploy/turnserver.conf.exampleto/etc/turnserver.conf(or todeploy/turnserver.conffor Compose). Fill in the secret (openssl rand -hex 32), your domain as the realm, and your public address. If people may reach each other through this same machine, allow its own public address withallowed-peer-ip.Open its ports
UDP and TCP 3478, and UDP 49160 to 49200.
Tell the relay
In the relay's settings file, set the same secret and where coturn is, then restart the relay:
GHOST_TURN_SECRET=the-secret-from-turnserver.conf GHOST_TURN_URLS=turn:relay.example.com:3478?transport=udp,turn:relay.example.com:3478?transport=tcpThe relay then hands each call short-lived credentials made with that secret.
A link helper
Optional. The apps can also make direct links between a person's own devices and their friends' devices. Two devices on one network link by themselves. Across networks they need a link helper: a server both can reach, which tells each the address the internet sees it at, passes their first packets, and carries their traffic for as long as no straight path can be made.
It is iroh's relay server, iroh-relay. It is not the Uplink relay, and the two know nothing of each other. The app ships with none: it uses the ones its relay names, and with none named its devices link only on one network. A link helper sees which device ids link, from which addresses, and how much they send. It never sees an account's name or what is said.
Build it
tool/build-link.sh hoston the server itself (Rust 1.91 or later) givesbuild/link/host/iroh-relay. Nothing prebuilt is fetched.Its settings
Copy
relay/deploy/link-helper.toml.exampleto/etc/ghost-link/config.tomland put your relay's name in it. As written the helper shares a machine with the web server that has ports 80 and 443, so it takes a port of its own and apps reach it athttps://relay.example.com:7843. Copy the settings' names, don't retype them: the server passes over one it doesn't know without a word.A certificate
It needs a certificate for that name, as two files where the settings say (
/etc/ghost-link/certs/relay.example.com.crtand.key, readable by the helper's user). The web server already has one: copy the pair, and copy it again whenever it is renewed. The helper reads the two files again once a day, so nothing needs restarting.The service
relay/deploy/ghost-link.service, with the steps at its top: a user of its own with no shell, and nothing writable but its own folder.Open its ports
TCP 7843, where apps reach it, and UDP 7842, where it tells a device its address. Keep that number: apps look for it there. 7844 and 7845 are for the machine itself and stay closed.
Tell the relay
In the relay's settings file, then restart the relay. Its hub hands the address to each app as it signs in.
GHOST_LINK_HELPERS=https://relay.example.com:7843
Then check it:
curl https://relay.example.com:7843/healthz # {"status":"ok","version":"1.5.0","git_hash":"unknown"}
cd native/link-check
cargo run -- https://relay.example.com:7843 # two devices sign in, link through it and straight; exits 0
Talking to other relays
Optional, and off unless you switch it on. Off, your relay is an island: its people reach only each other through it. To let them be friends with people on other relays, set two things in the settings file and restart the relay:
GHOST_FED=open # or: list, with GHOST_FED_ALLOW=relay.example.org,another.example.net
GHOST_PUBLIC_HUB=wss://relay.example.com/hub # your relay's own hub address, as the world reaches it
openlinks with any relay that proves its key;listonly with the relays inGHOST_FED_ALLOW.GHOST_FED_BLOCKnames relays never linked with, in either mode.- The other relay has to have it on too, and not block yours. Friendship across relays takes both.
- Your relay must be reachable at
GHOST_PUBLIC_HUBfrom outside, since other relays dial it to check yours is who it says. It must also be able to dial out on port 443. - It then keeps a key of its own in its data folder (
relay-key.json). Keep it, and keep it private: it is who your relay is to the others. - It sees one thing more: which of its people talk to people on which other relay, and when. Still never what.
As it starts, the relay says whether it talks to other relays, and its own name. That name is what another relay's keeper puts in their list to name yours. In the app, Settings › Routes then shows Passes messages to other relays. What crosses relays and what doesn't is on the Routes page.
Check it works
curl https://relay.example.com/ # Ghost Messaging relay
curl https://relay.example.com/market # {"ok":true,"open":false,...} with GHOST_MARKET_ON=0
journalctl -u ghost-relay -f # or: docker compose logs -f relay
The program says on start what it has: pairings and handles kept, Files spaces, whether a TURN server is set, and which sign-ins are on.
Point the app at it
On each device, open Settings › Routes › Relay server. Type your relay's address (relay.example.com is enough; it becomes wss://relay.example.com/hub) and press Check it and use it.
The app connects and waits for the hub's greeting. If an Uplink relay doesn't answer, nothing changes and it says why. If one does, it says what moving means and switches only when you say so. The section always shows which relay is in use, and Go back to Uplink's relay switches back in one press.
Everyone you want in a circle, a space or a call with has to set the same address. More about this screen is on the Routes page.
Keep it updated
- With Docker Compose:
docker compose pull && docker compose up -dinrelay/deploy. - With systemd: download the newer release (or build again), then
sudo install -m 755 ghost-relay /opt/ghost-relay/ghost-relayandsudo systemctl restart ghost-relay. - The link helper: build again, install the program over the old one, and
sudo systemctl restart ghost-link.
A restart drops whoever is connected, and the apps reconnect by themselves. It also loses held packets and presence, which are only in memory unless you set GHOST_HUB_KEEP_HELD=1.
The same guide, with more about how relays talk to each other, is in the repository: docs/SELF_HOSTING.md.
Docs