Run a relay

Hide a home server's address with Flaq Relay: what the relay sees, setting one up on a VPS with access keys and monthly allowances, and turning it on in the admin console.

4 min read

A server at home gives its address to the people with its invite link and to its members, as any server they connect to directly would. Hide my home address sends everything through a Flaq Relay instead, so the apps, and Connect, see only the relay's address. You can run a relay yourself on a rented server, or use one run by someone you trust.

If someone else runs the relay, they give you its address and an access key: skip to Turn it on.

What the relay sees#

The server keeps one tunnel open to the relay. The relay gives the server a public UDP port of its own and forwards packets between that port and the server. The encrypted connection inside still runs from each app to the server, checked against the server's key, so the relay passes on packets it can't read.

Who Sees
The apps and the server's members The relay's address, never the home's
Connect The relay's address; the server reaches Connect through the relay too
The relay's operator The home's address, and how much traffic passes

In this mode the server opens no router port and offers no other way in. While the relay is down, the server is listed nowhere and gives out no route, rather than fall back to the home's address.

What it needs#

  • A VPS whose public IPv4 address is on its own network interface: ip -4 addr shows it. That is the case at Hetzner, DigitalOcean, Vultr or Linode. On AWS, Google Cloud or Azure the public address is translated, and the relay can't hand out ports on it.
  • A host name with an A record for that address, such as relay.example.com.
  • Open in the firewall: UDP 7443 (the servers' tunnels), UDP 40000-40999 (one port for each server using the relay), and TCP 80 while the certificate is issued and renewed.
  • Bandwidth: everything a server's people send and receive passes through, roughly 20 MB a person a day, most of it files.

Set it up#

mkdir flaq-relay && cd flaq-relay
curl -O https://raw.githubusercontent.com/hyprlab/flaq/main/relay/docker-compose.yml
curl -o .env https://raw.githubusercontent.com/hyprlab/flaq/main/relay/.env.example
mkdir certs

Get the certificate as in Certificates, into certs/, replacing connect with relay in the hook. Then fill in .env:

Variable
RELAY_PUBLIC The public IPv4 address, as ip -4 addr shows it
RELAY_PORT The UDP port the tunnels arrive on, 7443
RELAY_PORTS The UDP ports handed to servers, 40000-40999: as many as servers you will carry
RELAY_KEYS The access keys, each with the bytes it may carry a month: key bytes, key bytes

During the 1.0 beta, also set IMAGE_TAG=beta.

Access keys#

Make one access key for each server you carry, so each has its own allowance and can be cut off alone:

openssl rand -hex 16

RELAY_KEYS=3f9c…e1 30000000000, 8b20…7a 5000000000 gives the first 30 GB a month and the second 5 GB. 50 GB is roughly a month for a server of 50 people.

Start it#

docker compose up -d
docker compose logs relay       # flaq-relay: gates on UDP 0.0.0.0:7443

The relay uses the host's network, as its compose file says, since it opens ports on the machine's own address.

To take a key back, remove it from RELAY_KEYS and run docker compose up -d. Each key's traffic this month is kept in the relay-data volume.

Turn it on#

On the Messaging Server's admin console, open Flaq Connect, and under Hide my home address:

  1. Enter the relay's address with its port, such as relay.example.com:7443.
  2. Enter the access key.
  3. Tick Send everything through a relay.

Status then reads "Through the relay, at" the relay's address, with the traffic used this month. Nothing needs forwarding on your router.

If something is wrong#

  • "The relay can't be reached". The relay's address or port is wrong, its UDP port is closed in its firewall, or its certificate doesn't match its host name. The reason follows on the same line.
  • The relay's log says "no port left in the relay's range". RELAY_PUBLIC isn't an address of the machine's own (ip -4 addr), or every port in RELAY_PORTS is taken: widen the range and open it in the firewall.
  • "That access key isn't one this relay gave out." The key on the console doesn't match one in RELAY_KEYS, or the relay wasn't restarted after it was added.
  • "This access key has used its traffic for the month." The key's allowance is used up until the first of next month, or until the relay's operator raises it.
  • The relay stops at start with "reading /certs/…". The certificate files are missing, or uid 1000 can't read them: run the certificate hook again, or sudo chown 1000 certs/*.pem.