Our cPanel servers use CloudLinux NodeJS selector, CageFS, and LiteSpeed Web Server.
When managing a NodeJS app with a CloudLinux NodeJS selector, LSWS is a proxy for ws:// requests to the NodeJS backend when a WebSocket upgrade is requested. Best of all, no additional configuration is needed!
When testing a direct connection to a NodeJS server, use the following command:
ws://...
When accessing a NodeJS server through an LSWS HTTPS proxy server, use the following command:
wss://...
When a NodeJS server is started, the TCP socket is replaced with an auto-generated Unix domain socket. Hence, direct access to 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 = 'Yaay! 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 and the result should be:
Yaay! It works! NodeJS 10.0
Conclusion
If you are running a NodeJS server, please ensure that you run it on either port 80 or 443.