Skip to content

Configuration

Complete reference for all environment variables and configuration options.

Core Settings

VariableDefaultDescription
HTTP_ADDR:8080HTTP listen address, format host:port
ALLOWED_ORIGIN*CORS allowed origin, * means any

Authentication

VariableFormatDescription
AUTH_TOKENstringGlobal access token
ROOM_TOKENSroom1:tok1;room2:tok2Per-room token mapping
JWT_SECRETstringJWT HMAC signing key
JWT_AUDIENCEstringRequired JWT audience claim
ADMIN_TOKENstringAdmin API access token

Authentication Priority: Room-specific Token → Global Token → JWT → No authentication

WebRTC / ICE Configuration

VariableDefaultDescription
STUN_URLSstun:stun.l.google.com:19302STUN server list
TURN_URLS-TURN server list
TURN_USERNAME-TURN username
TURN_PASSWORD-TURN password

Example:

bash
STUN_URLS=stun:stun1.l.google.com:19302,stun:stun2.l.google.com:19302
TURN_URLS=turn:turn.example.com:3478,turns:turn.example.com:5349
TURN_USERNAME=myuser
TURN_PASSWORD=mypassword

Recording Configuration

VariableDefaultDescription
RECORD_ENABLED0Enable recording, set to 1 to enable
RECORD_DIRrecordsRecording file storage directory

S3 Upload Configuration

VariableDefaultDescription
UPLOAD_RECORDINGS0Enable upload, set to 1 to enable
DELETE_RECORDING_AFTER_UPLOAD0Delete local file after upload
S3_ENDPOINT-S3/MinIO endpoint address
S3_REGION-S3 region
S3_BUCKET-Target bucket name
S3_ACCESS_KEY-Access Key ID
S3_SECRET_KEY-Secret Access Key
S3_USE_SSL1Use HTTPS connection
S3_PATH_STYLE0Use path-style addressing
S3_PREFIX-Object key prefix

MinIO Example:

bash
S3_ENDPOINT=minio.example.com:9000
S3_ACCESS_KEY=minioadmin
S3_SECRET_KEY=minioadmin
S3_BUCKET=recordings
S3_USE_SSL=0
S3_PATH_STYLE=1

Rate Limiting Configuration

VariableDefaultDescription
RATE_LIMIT_RPS0Requests per second per IP, 0 disables
RATE_LIMIT_BURST0Burst capacity

Room Limits

VariableDefaultDescription
MAX_SUBS_PER_ROOM0Max subscribers per room, 0 = unlimited

TLS Configuration

VariableDescription
TLS_CERT_FILETLS certificate file path
TLS_KEY_FILETLS private key file path
bash
TLS_CERT_FILE=/etc/ssl/cert.pem
TLS_KEY_FILE=/etc/ssl/key.pem

Debug Configuration

VariableDefaultDescription
PPROF0Enable pprof endpoints
OTEL_SERVICE_NAMElive-webrtc-goOpenTelemetry service name

Environment File

Create .env.local file for development:

bash
# Server configuration
HTTP_ADDR=:8080
ALLOWED_ORIGIN=*

# Authentication
AUTH_TOKEN=your-secret-token
# ROOM_TOKENS=room1:token1;room2:token2
# JWT_SECRET=jwt-signing-secret

# WebRTC configuration
# STUN_URLS=stun:stun.l.google.com:19302
# TURN_URLS=turn:turn.example.com:3478

# Recording
RECORD_ENABLED=1
RECORD_DIR=records

# Rate limiting
RATE_LIMIT_RPS=10
RATE_LIMIT_BURST=20

Full Docker Example

bash
docker run --rm -p 8080:8080 \
  -e HTTP_ADDR=:8080 \
  -e AUTH_TOKEN=mytoken \
  -e RECORD_ENABLED=1 \
  -e RECORD_DIR=/records \
  -e UPLOAD_RECORDINGS=1 \
  -e S3_ENDPOINT=s3.amazonaws.com \
  -e S3_BUCKET=my-bucket \
  -e S3_ACCESS_KEY=$AWS_ACCESS_KEY_ID \
  -e S3_SECRET_KEY=$AWS_SECRET_ACCESS_KEY \
  -v $(pwd)/records:/records \
  live-webrtc-go:latest

Kubernetes Deployment

yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: live-webrtc
spec:
  replicas: 3
  selector:
    matchLabels:
      app: live-webrtc
  template:
    metadata:
      labels:
        app: live-webrtc
    spec:
      containers:
      - name: live-webrtc
        image: live-webrtc:latest
        ports:
        - containerPort: 8080
        env:
        - name: HTTP_ADDR
          value: ":8080"
        - name: AUTH_TOKEN
          valueFrom:
            secretKeyRef:
              name: live-webrtc-secret
              key: auth-token
        volumeMounts:
        - name: records
          mountPath: /records
      volumes:
      - name: records
        persistentVolumeClaim:
          claimName: records-pvc

Troubleshooting

IssuePossible CauseSolution
publisher already exists in this roomRoom already has a publisherUse a different room name or wait for publisher to disconnect
unauthorizedAuthentication failedCheck token or JWT configuration
too many requestsRate limit triggeredIncrease RATE_LIMIT_BURST or wait
no active publisher in roomRoom has no publisherEnsure publisher is connected
subscriber limit reachedMAX_SUBS_PER_ROOM hitIncrease limit or wait for subscribers to disconnect
ICE connection failedNAT traversal issueConfigure TURN server

Debugging Steps

  1. Check Service Status: curl http://localhost:8080/healthz
  2. View Metrics: curl http://localhost:8080/metrics
  3. Enable pprof: PPROF=1 go run ./cmd/server
  4. Check Logs: Focus on ERROR level logs

Released under the MIT License.