Exclusive Metin2 game shield on FreeBSD: Automatic siege mode, VIP list, and whitelist from your dashboard. See how it works
Create a server

Guide

How to Set Up a WebSocket Server

WebSockets keep a bidirectional connection (chats, dashboards, games). Here: a minimal Node server plus Nginx in front.

Steps

  1. Install Node.js LTS if needed and create a project:

    mkdir -p ~/ws-demo && cd ~/ws-demo
    npm init -y && npm install ws
  2. Create server.js with a ws server on port 8080 and start it (or under screen/tmux):

    node server.js
  3. In Nginx, proxy with connection upgrade (example location):

    # location /ws/ { proxy_pass http://127.0.0.1:8080/; proxy_http_version 1.1;
    # proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; }
    sudo nginx -t && sudo systemctl reload nginx
  4. Test from a browser or client: wss://YOUR_DOMAIN/ws/ (with SSL).

Tips

  • Bind to 127.0.0.1 only and let Nginx/Certbot handle TLS.
  • In production use a process manager (systemd or PM2), not a bare Node in SSH.

ext step

VPS ready for realtime APIs: Deploy your Cloud VPS.

Related guides