Reverse proxy
To serve Razzia on a domain name, with HTTPS, or next to other apps on the same server, put it behind a reverse proxy.
Razzia serves everything on a single port, 3000: the web app, the API at /api, and the WebSocket connection at /ws that runs the games. The proxy only has to forward everything to this port and let WebSocket connections through. Without that, the app loads but players stay stuck on “connecting”.
Examples
Section titled “Examples”In these examples, razzia is the address of the container, like localhost:3000 or a Compose service on the same network. They are a starting point: adapt them to your setup, for example to add HTTPS.
server { listen 80; server_name quiz.example.com;
location / { proxy_pass http://razzia:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_read_timeout 3600s; client_max_body_size 101m; }}Upgrade,Connectionand the longproxy_read_timeoutkeep the WebSocket connection alive for the whole game.client_max_body_sizelets media uploads through. Nginx refuses bodies over 1 MB by default, and Razzia accepts files up to 100 MB.
If this Nginx sits behind Cloudflare, also forward the real visitor IP:
proxy_set_header CF-Connecting-IP $http_cf_connecting_ip;Traefik forwards WebSocket connections without extra configuration. With Docker labels:
services: razzia: image: ralex91/razzia:latest volumes: - ./config:/app/config env_file: - .env labels: - "traefik.enable=true" - "traefik.http.routers.razzia.rule=Host(`quiz.example.com`)" - "traefik.http.routers.razzia.entrypoints=web" - "traefik.http.services.razzia.loadbalancer.server.port=3000" networks: - traefikCaddy forwards WebSocket connections with a plain reverse_proxy, and sets up HTTPS automatically:
quiz.example.com { reverse_proxy razzia:3000}Other proxies
Section titled “Other proxies”Any reverse proxy works if it:
- forwards every path (
/,/api,/ws,/media,/branding) to port3000; - passes the
UpgradeandConnectionheaders, for the WebSocket connection on/ws; - uses a long read or idle timeout, since players stay connected for the whole game, often longer than the usual 60 seconds;
- accepts request bodies up to 100 MB, for media uploads.