Quick Start Configuration HTTP API SDKs

Configuration

Relay is configured entirely via environment variables. No config files needed.

Environment Variables

All configuration is handled through environment variables. The table below lists every option with its default value.

VariableDefaultDescription
RELAY_HOST0.0.0.0IP address to bind to
RELAY_PORT6001Port to listen on
RELAY_APP_IDrelay-appApplication identifier
RELAY_APP_KEYrelay-keyPublic app key (shared with clients)
RELAY_APP_SECRETSecret key for signing auth tokens (keep private!)
RELAY_MAX_CONNECTIONS10000Maximum concurrent WebSocket connections
RELAY_MAX_CHANNEL_NAME_LENGTH200Maximum channel name length in characters
RELAY_MAX_EVENT_PAYLOAD_KB100Maximum event payload size in KB
RELAY_PING_INTERVAL120Seconds between server pings
RELAY_PING_TIMEOUT30Seconds to wait for pong before disconnecting
RELAY_DASHBOARD_ENABLEDtrueEnable the built-in web dashboard
RELAY_DASHBOARD_PATH/dashboardURL path for the dashboard
RELAY_DEBUGfalseEnable verbose debug logging

Using a .env File

Relay automatically loads a .env file from the working directory if one exists.

env
# .env
RELAY_APP_KEY=my-app-key
RELAY_APP_SECRET=my-super-secret-key
RELAY_PORT=6001
RELAY_DEBUG=true
RELAY_DASHBOARD_ENABLED=true

Multi-App Support (apps.json)

For multi-tenant deployments, create an apps.json file to register multiple applications on a single server instance.

json
[
  {
    "id": "app-1",
    "key": "key-1",
    "secret": "secret-1",
    "max_connections": 1000
  },
  {
    "id": "app-2",
    "key": "key-2",
    "secret": "secret-2",
    "max_connections": 5000
  }
]

When apps.json is present, the RELAY_APP_* environment variables are ignored. Each app gets its own isolated namespace of channels and connections.

apps.json Fields

FieldRequiredDescription
idYesUnique app identifier (used in API paths)
keyYesPublic key (clients connect with this)
secretYesSecret for HMAC signing
max_connectionsNoPer-app connection limit

Warning: In production, always change the default app secret. The default value relay-secret-change-me is not secure.

Docker Deployment

Basic

bash
docker run -d -p 6001:6001 \
  -e RELAY_APP_KEY=my-key \
  -e RELAY_APP_SECRET=my-secret \
  relayhq/relay:latest

With .env file

bash
docker run -d -p 6001:6001 \
  --env-file .env \
  relayhq/relay:latest

With apps.json

bash
docker run -d -p 6001:6001 \
  -v $(pwd)/apps.json:/relay/apps.json \
  relayhq/relay:latest

Docker Compose

yaml
version: '3.8'
services:
  relay:
    image: relayhq/relay:latest
    ports:
      - "6001:6001"
    environment:
      RELAY_APP_KEY: my-key
      RELAY_APP_SECRET: my-secret
      RELAY_DEBUG: "false"
    restart: unless-stopped

Production Checklist

Before deploying Relay to production, make sure you have addressed the following: