moq-relay is a server that forwards subscriptions from publishers to subscribers, providing caching, deduplication, and fan-out at scale.
Overview
moq-relay is designed to be deployed in datacenters, relaying media across multiple hops to:- Fan-out: Distribute content to many subscribers efficiently
- Deduplicate: Cache content to reduce upstream bandwidth
- Cluster: Form a mesh across regions for global scale
- Route: Forward subscriptions to the optimal origin
The relay operates on rules encoded in the moq-lite protocol header. It knows nothing about your application, media codecs, or business logic.
Installation
Quick Start
Run a local relay for development:https://localhost:4443 with:
- UDP for QUIC connections
- TCP for HTTP/WebSocket fallback
- Anonymous access enabled at
/anonpath
Configuration
moq-relay is configured using a TOML file. Here’s a complete example:relay.toml
Server Configuration
Socket address to bind for QUIC connections (UDP)Examples:
"[::]:4443"- All interfaces, IPv6 and IPv4"127.0.0.1:4443"- Localhost only"0.0.0.0:4443"- All interfaces, IPv4 only
Path to TLS certificate file (PEM format)
Path to TLS private key file (PEM format)
Hostnames to generate self-signed certificates for (development only)
Web Server Configuration
Socket address to bind for HTTP/WebSocket connections (TCP)Used for:
- Certificate fingerprint endpoint
- Track listing API
- WebSocket fallback
HTTP Endpoints
The relay provides several HTTP endpoints for debugging and integration:GET /certificate.sha256
Returns the SHA-256 fingerprint of the TLS certificate:GET /announced/*prefix
Lists all announced tracks with the given prefix:GET /fetch/*path
Fetches the latest group from a track:Authentication
The relay supports JWT-based authentication with path-based access control.Configuration
Supported Algorithms
Symmetric:- HMAC-SHA256 (HS256)
- HMAC-SHA384 (HS384)
- HMAC-SHA512 (HS512)
- RSA-SHA256 (RS256)
- RSA-SHA384 (RS384)
- RSA-SHA512 (RS512)
- RSA-PSS-SHA256 (PS256)
- RSA-PSS-SHA384 (PS384)
- RSA-PSS-SHA512 (PS512)
- ECDSA-SHA256 (ES256)
- ECDSA-SHA384 (ES384)
- EdDSA (EdDSA)
Token Claims
Tokens must include path-based authorization:Generating Tokens
Use the moq-token CLI:Using Tokens
Pass tokens as query parameters:Clustering
Scale across multiple relays in different regions using clustering.Architecture
Clustering uses a simple root-and-leaf topology:- Root node: Discovers cluster members and routes subscriptions
- Edge nodes: Accept client traffic and consult root for routing
Configuration
Root Node
Edge Nodes
Command Line Arguments
Hostname/IP of the root node. If missing, this node is the root.
Public hostname/IP of this instance. Required for published broadcasts to be available on other relays.
How It Works
- Edge nodes connect to the root node
- Publishers announce broadcasts to their edge node
- Edge node advertises broadcasts to root
- Subscribers query their edge node
- Edge node consults root for routing
- Root directs edge to the publisher’s edge
- Edge nodes form direct connections
Features
moq-relay supports different QUIC backends:Running in Production
Systemd Service
/etc/systemd/system/moq-relay.service
Docker
Iroh Support
Enable P2P connections via Iroh:iroh://<ENDPOINT_ID>h3+iroh://<ENDPOINT_ID>/path
Monitoring
moq-relay logs to stdout using the configured log level:Resources
- Source Code - GitHub repository
- Example Config - Full configuration example
- Authentication Guide - JWT token setup
Next Steps
moq-token
Set up authentication
moq-cli
Publish media to your relay
moq-native
Connect clients to your relay
Authentication
Learn about JWT tokens