Summary

RemoteViz uses WebSocket protocol to make possible the communication between the client and the service. Without any web servers between the client and the RemoteViz service, a WebSocket connection can be established smoothly. However, in production environments, the web page requests are handled by a web server and only the web server port (port 80 by default) is open from the outside in order to guarantee security. To use the same port and domain for the HTTP requests and the Websocket requests, the websocket traffic has to be routed through the web server. This document explains how to configure NodeJS server as reverse proxy to handle web page requests and websocket traffic over the same port and domain.

NodeJS Installation

NodeJS proxing library

To route websocket traffic, we use the library node-http-proxy. It is an HTTP programmable proxying library that supports websockets for NodeJS server. It is suitable for implementing components such as proxies and load balancers.

NodeJS Configuration

In the next section, we consider that the NodeJS web server is bound to the public port 80 (non-SSL) or 443 (SSL) and the RemoteViz service is bound to the private port 8080 (behind a firewall). Here is a simple web server (written in NodeJS) used to handle HTTP requests and WebSocket requests. This example uses an automatic detection of the websocket request by examining the HTTP header for the "Upgrade: WebSocket" line. All websocket traffic will be redirected to the RemoteViz service.