Skip to content

Deploy a WebSocket service

Run a real-time WebSocket server and reach it over WSS through the platform edge.

WebSocket deployment - real-time WebSocket server behind the platform edge

What you'll run

A WebSocket server container on one port inside your instance. The node edge terminates TLS and proxies the upgrade, so clients connect with wss:// to the same HTTPS URL as any other site. No ports 80/443 need to be published.

docker-compose.yml

yaml
services:
ws:
image: ghcr.io/yourorg/ws-server:latest
restart: unless-stopped
ports: ["8080:8080"]
environment: { REDIS_URL: "redis://redis:6379" }
redis:
image: redis:7-alpine
restart: unless-stopped
volumes: ["redis_data:/data"]
volumes: { redis_data: {} }

Set the origin port

In the dashboard, open Networking, set the web site origin port to 8080, and save. Then use the HTTPS URL with your WebSocket path:

bash
wss://<hostname>.nairacloud.xyz/ws

Launch & verify

bash
$ docker compose up -d
$ websocat wss://<hostname>.nairacloud.xyz/ws

The edge forwards the original Host, Origin, and upgrade headers. Validate Origin in your server if you need to restrict which sites can connect.

Optional custom domain

Add an A record pointing at the node IP, attach the hostname under Custom domain, and use wss://your-domain.com/ws. Keep the DNS record DNS-only if your provider proxies traffic.

Practical -- try it now

WebSocket server in 5 minutes

  1. Provision an instance, SSH in, and run the compose file above.
  2. In Sites, set the web origin to 8080.
  3. Connect with websocat wss://<your-url>/ws.
Ask a question...
Ctrl+I