How eooce/node-ws works
Purpose and Runtime
Node-ws is a lightweight Node.js Serverless/PaaS proxy service implementing VLESS and Trojan over WebSocket without a bundled proxy core. Its primary runtime entry point is index.js; package execution metadata is in package.json. It also serves a minimal HTTP-facing page from index.html.
Process Entry and Configuration
The Node process starts the HTTP/WebSocket service in index.js. Runtime behavior is environment-driven: PORT selects the listener, UUID configures proxy identity, and DOMAIN supplies the externally reachable hostname. SUB_PATH controls the subscription-information endpoint, while AUTO_ACCESS can enable periodic self-access/keepalive behavior.
Paths: index.js, package.json, index.html
HTTP and WebSocket Boundary
The service accepts ordinary HTTP requests and WebSocket upgrade traffic on the same Node listener. HTTP is used for the landing/cover response and subscription/node-information route; upgraded WebSocket connections carry the VLESS or Trojan protocol streams. This boundary lets deployments sit behind domain reverse proxies or CDN Worker/Snippet forwarding.
Paths: index.js, index.html, README.md
Proxy Protocol Stage
Incoming WebSocket byte streams are interpreted as either VLESS or Trojan authentication/request data. After protocol validation, the service establishes outbound TCP connectivity to the requested target and relays data bidirectionally between the WebSocket and that socket. Credentials are centered on the configured UUID, with the implementation intentionally relying on the Node WebSocket ecosystem rather than an external proxy binary.
Paths: index.js, package.json
Subscription and Deployment Interface
A path derived from SUB_PATH exposes connection/node information for clients. Generated endpoint information depends on DOMAIN, including nonstandard-port deployment cases. The documented hosting model targets Node-capable PaaS and DirectAdmin application hosting, and supports external CDN/reverse-proxy fronting.
Paths: index.js, web-hosting.md, README.md
Nezha Monitoring Integration
The process can optionally launch/connect an embedded Nezha agent integration. NEZHA_SERVER, NEZHA_PORT, and NEZHA_KEY select server endpoint and credentials; the documented variables support both Nezha v0 and v1 conventions. NAME provides the node-name prefix. This monitoring path is optional and separate from proxy request forwarding.
Paths: index.js, README.md
Packaging and Delivery
The repository packages the service as a Node application and provides a container build definition. GitHub Actions include workflows for Docker/image delivery and Go/Hug-related binary/image builds, indicating multiple deployment artifact targets beyond direct Node hosting.
Paths: Dockerfile, .github/workflows/build-image.yml, .github/workflows/build-golang-docker-image.yml
Main entry points: index.js HTTP/WS Server · Dockerfile Container Build · package.json Package Metadata · build-image.yml Image Delivery Workflow
Components 16
Node Service
- Package Metadata · Defines application execution and dependencies.
package.json - HTTP/WS Server · Starts the shared HTTP and WebSocket listener.
index.js - Environment Settings · PORT, UUID, DOMAIN, SUB_PATH, and AUTO_ACCESS control service behavior.
index.js - Landing Page
index.html - Subscription Endpoint · Publishes node information derived from SUB_PATH and DOMAIN.
index.js - Embedded Nezha Agent · Optionally connects using NEZHA_SERVER, NEZHA_PORT, and NEZHA_KEY.
index.js
Traffic Flow
- WebSocket Upgrade · Accepts proxy streams on the HTTP listener.
index.js - VLESS / Trojan Parser · Validates incoming authentication and target requests.
index.js - TCP Relay · Relays bytes bidirectionally after target connection.
index.js - Requested Target
Delivery
- Container Build
Dockerfile - Image Delivery Workflow
.github/workflows/build-image.yml - Go/Hug Build Workflow · Builds additional binary and image artifacts.
.github/workflows/build-golang-docker-image.yml
Other components
- HTTP and Proxy Clients
- CDN / Reverse Proxy
- Nezha Server
Connections 16
- Package Metadata → HTTP/WS Server: runs
- Environment Settings → HTTP/WS Server: configures
- HTTP and Proxy Clients → CDN / Reverse Proxy: requests
- CDN / Reverse Proxy → HTTP/WS Server: forwards
- HTTP and Proxy Clients → HTTP/WS Server: direct access
- HTTP/WS Server → Landing Page: serves HTTP
- HTTP/WS Server → Subscription Endpoint: routes HTTP
- HTTP/WS Server → WebSocket Upgrade: upgrades
- WebSocket Upgrade → VLESS / Trojan Parser: byte stream
- VLESS / Trojan Parser → TCP Relay: validated request
- TCP Relay → Requested Target: outbound TCP
- HTTP/WS Server → Embedded Nezha Agent: optionally starts
- Embedded Nezha Agent → Nezha Server: reports to
- Container Build → HTTP/WS Server: packages
- Image Delivery Workflow → Container Build: builds and delivers
- Go/Hug Build Workflow → Container Build: builds image artifacts