Settings

Every environment setting of the Messaging Server, Flaq Connect and Flaq Relay, with its default and what it does, and the two settings the desktop app reads.

5 min read

Each part of Flaq is set up by a .env file next to its docker-compose.yml. The example files, .env.example, list what the compose files pass in. After changing .env, apply it with:

docker compose up -d

The Messaging Server#

Everything is optional: the server starts with none of it set, though you should set your own POSTGRES_PASSWORD before the first start.

Variable Default What it does
IMAGE_TAG latest The image to run: latest for stable, beta, or a version such as 1.4.0 to pin one
POSTGRES_PASSWORD flaq The database password, used by both the database and the server. Set it before the first start: changing it later needs the database changed too
APP_NAME Flaq What the server calls itself until a name is set in the admin console
APP_TAGLINE Private messaging on your own server, end-to-end encrypted. The line under the name, on the sign-in page and in About
SECRET_KEY generated Signs the admin console's sessions. If unset, one is generated and kept in the data volume, so sessions survive a restart
KDF_ITERATIONS 600000 PBKDF2 rounds for accounts made from now on
WEB_WORKERS 2 Web processes. Each holds thousands of open connections; add one per CPU core you want to use
SESSION_COOKIE_SECURE 0 1 when the server is served over HTTPS, so the console's cookies are Secure
TRUST_PROXY 0 How many reverse proxies are in front. 0 trusts no X-Forwarded-* header; a number higher than the real one lets clients forge their address
PUBLIC_URL empty The server's address, such as https://chat.example.com. When it is https://, plain-HTTP visits are sent there. Its host is also the home in your accounts' handles
FLAQ_GATE 1 0 leaves out the gate, which lists the server on Flaq Connect. The gate does nothing until Flaq Connect is turned on in the admin console
ALLOW_REGISTRATION 1 Whether anyone can create an account from an app
SIGN_UPS_PER_HOUR 10 New accounts the apps may make from one address in an hour
MAX_UPLOAD_MB 1024 The largest file anyone can send, in MB
TURNSTILE_SITE_KEY, TURNSTILE_SECRET_KEY empty Cloudflare Turnstile keys for the admin console's sign-in. Usually set in the console instead (Security), which checks the keys before saving them
DATABASE_URL set by compose postgresql://...; without it, SQLite in the data volume
REDIS_URL set by compose Without it, the server runs one web process and keeps events in that process
DATA_DIR /data Where files and keys live inside the container

The admin console wins

ALLOW_REGISTRATION, MAX_UPLOAD_MB and the Turnstile keys are only defaults for a fresh install. Once they are changed in the admin console (Server settings or Security), what is saved there wins. With both Turnstile keys set and nothing saved in the console, Turnstile is on with those keys.

KDF_ITERATIONS is not in the compose file or .env.example. Like the gate's settings below, it takes effect only once it is added to the flaq service's environment in docker-compose.yml.

The gate#

The gate ships in the server's image and reads these. They are not in the compose file; the defaults are what it uses.

Variable Default What it does
FLAQ_GATE_PORT 4433 The UDP port the apps reach the gate on
FLAQ_UPSTREAM 127.0.0.1:8000 Where the server listens, on loopback
FLAQ_GATE_UPNP on 0 turns off asking the router to open the port
FLAQ_GATE_MDNS on 0 turns off announcing the server on the local network

Flaq Connect#

The variables in Connect's .env:

Variable Default What it does
IMAGE_TAG latest The image to run: latest, beta, or a version
CONNECT_HOST required Its host name, with an A record pointing at the machine. Invite links lead to it, and servers prove their keys to it by name, so it can't change later without every server listed there adding it again
CONNECT_HTTPS_PORT 443 The host port its HTTPS API listens on. Behind a reverse proxy that holds 443, another port for the proxy to forward to. UDP 443 stays as it is
CONNECT_TRUST_PROXY 0 1 behind that proxy, so Connect's limits count each visitor's own address, from the last X-Forwarded-For address, rather than the proxy's
CONNECT_OPERATOR empty Who runs it, shown on its home page and in /.well-known/flaq. Once changed in the console, the console's wins
CONNECT_POLICY_URL empty Its policy, likewise
CONNECT_DOWNLOAD_URL https://github.com/hyprlab/flaq/releases Where the invite page sends people who don't have the app yet

The program also reads these. The compose file sets the certificate paths; the rest keep their defaults unless added to the connect service's environment:

Variable Default What it does
CONNECT_CERT, CONNECT_KEY /certs/fullchain.pem, /certs/privkey.pem The certificate for the host with its chain, and its key
CONNECT_HTTPS 0.0.0.0:443 Where the API listens inside the container
CONNECT_QUIC 0.0.0.0:443 Where servers' control connections arrive (UDP)
CONNECT_QUIC_PORT unset The UDP port the world reaches that on, when a port forward changes it
CONNECT_DB /data/connect.db The SQLite file
CONNECT_PROBE_PRIVATE unset 1 checks addresses in private networks too: for a test on one machine or in a lab only

Home accounts and their mail server are set in Connect's console, on its Settings page, not in .env.

Flaq Relay#

The variables in the relay's .env:

Variable Default What it does
IMAGE_TAG latest The image to run: latest, beta, or a version
RELAY_PUBLIC required The machine's public IPv4 address, as it appears on its network interface (ip -4 addr). The ports handed to servers are on it
RELAY_PORT 7443 The UDP port servers' tunnels arrive on
RELAY_PORTS 40000-40999 The UDP ports handed to servers, one each. Open all of them in the firewall
RELAY_KEYS required The access keys, each with the bytes it may carry a month, separated by commas: key bytes, key bytes. 50000000000 is 50 GB, roughly a month for a server of 50 people

The program also reads:

Variable Default What it does
RELAY_BIND 0.0.0.0:7443 Where tunnels arrive; the compose file makes it from RELAY_PORT
RELAY_CERT, RELAY_KEY /certs/fullchain.pem, /certs/privkey.pem in compose The certificate for the relay's host with its chain, and its key
RELAY_KEYS_FILE unset A file of access keys, in place of RELAY_KEYS
RELAY_USAGE /data/relay-usage.json Where each key's bytes this month are kept

The desktop app#

Two environment settings change how the app runs, for troubleshooting and development:

Variable What it does
FLAQ_DEBUG Set, the app says each step of reaching a server through Flaq Connect on standard error
FLAQ_CONNECT_ROOTS A PEM file of certificate authorities to trust besides the system's, for a development Connect with a certificate of its own. The gate reads it too