In our cPanel shared hosting servers we run CloudLinux NodeJS selector + CageFS + LiteSpeed Web Server.

For a NodeJS application managed by CloudLinux NodeJS selector, LSWS does an automatic ws:// proxy to the NodeJS backend, if the request does a WebSocket upgrade. No extra configuration required.

When direct connecting to a NodeJS server, test with:

ws://...

When going through a LSWS HTTPS proxy server, use:

wss://...

When a NodeJS server is started, the TCP socket is replaced with an auto-generated Unix domain socket, hence direct access the TCP port may fail.

To test, you can create a file with the name index.js. Place the following content in the file:

var http = require('http');
var server = http.createServer(function(req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    var message = 'It works!\n',
        version = 'NodeJS ' + process.versions.node + '\n',
        response = [message, version].join('\n');
    res.end(response);
});
server.listen();

Point your browser to http://domain.com/index.js

The result:

It works!
NodeJS 10.11.0

Note that any port specifications in the listen function are ignored. The server is processed by the Node.js function of LiteSpeed automatically.

Conclusion:

When you run a NodeJS server, the web server proxy the ports through ports 80 and 443. We do not open any other ports for security reasons.

Please if you run a NodeJS server make sure to run it over port 80 or 443.

Was this answer helpful? 0 Users Found This Useful (1 Votes)