Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
litespeed_wiki:cloudlinux:node.js_selector [2018/05/24 15:21]
Robert Perper [How to use CloudLinux Node.js Selector with LSWS]
litespeed_wiki:cloudlinux:node.js_selector [2020/01/29 15:11]
Shivam Saluja [Troubleshooting]
Line 1: Line 1:
-====== How to use CloudLinux Node.js Selector with LSWS ======+====== How to Use CloudLinux Node.js Selector with LSWS on cPanel or DirectAdmin ​======
  
-As JavaScript became one of the most popular programming languages, more and more customers ​demand ​Node.js hosting. CloudLinux Node.js Selector was introduced to facilitate the performance and functionality related to Node.js. ​ LSWS added CloudLinux Node.js Selector support starting from 5.3RC1 release.+As JavaScript became one of the most popular programming languages, more and more customers ​demanded ​Node.js hosting. CloudLinux Node.js Selector was introduced to facilitate the performance and functionality related to Node.js. ​ LSWS added CloudLinux Node.js Selector support starting from the 5.3RC1 release.
  
-There is virtually no downside to using this method. ​ All of your existing Node.js packages which can include Ghost or any homegrown software will run with virtually no changesthrough the Litespeed port.  Litespeed continues to serve all of your non-Node.js traffic and it will now additionally service the Node.js traffic. +There is virtually no downside to using this method. ​ All of your existing Node.js packages which can include Ghost or any homegrown softwarewill run with virtually no changes through the Litespeed port.  Litespeed continues to serve all of your non-Node.js traffic and it will now additionally service the Node.js traffic.
-===== LSWS Node.js Selector support out of the box  ===+
  
-Node.js ​Selector from Cloudlinux ​is supported ​by Litespeed Web server out of the box. You will need to follow the instructions in the CloudLinux ​Node.js ​selectorYou can refer to [[https://​docs.cloudlinux.com/​index.html?​node_js_selector.html|CloudLinux official documentation]].+Please be aware that CloudLinux ​Node.js ​selector supports **cPanel** and **DirectAdmin** servers (Plesk ​is not supported ​as it already has Node.js ​support.)If you have only CloudLinux but no above-supported control panel, it may not work. 
 +===== LSWS Node.js Selector Support Out of the Box  =====
  
 +Node.js Selector from Cloudlinux is supported by LiteSpeed Web Server out of the box without any extra configuration required on LSWS side. You will need to follow the instructions in the CloudLinux Node.js selector to make your node.js app working with Apache first before switching to LSWS. You can refer to the [[https://​docs.cloudlinux.com/​index.html?​node_js_selector.html|official CloudLinux documentation]].
  
-===== How to test Node.js ​with LSWS =====+===== How LiteSpeed Works with NodeJS Selector ​=====
  
-You can create file with the name index.js ​and content:+For a NodeJS application managed by CloudLinux NodeJS selector, LSWS does an automatic ''<​nowiki>​ws://</​nowiki>''​ 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  
 +<​code>​ws://​...</​code>​.  
 + 
 +When going through a LSWS HTTPS proxy server, use  
 +<​code>​wss://​...</​code>​.  
 + 
 +When a NodeJS server is started through LSWS NodeJS selector integration (mod_passenger),​ the TCP socket is replaced with an auto-generated Unix domain socket, hence direct access the TCP port may fail. 
 + 
 +===== How to Test Node.js with LSWS ===== 
 + 
 +You can create ​file with the name ''​index.js''​. Place the following ​content ​in the file:
  
 <​code>​var http = require('​http'​);​ <​code>​var http = require('​http'​);​
Line 24: Line 37:
 </​code>​ </​code>​
  
-Point your browser to http://​domain.com/​index.js+Point your browser to ''​http://​domain.com/​index.js''​. 
 + 
 +The result:
  
-The result is:+  It works! 
 +  NodeJS 10.11.0
  
-{{:​litespeed_wiki:​cloudlinux:​nodejs.png?400|}}+Note that any port specifications in the listen function are ignored. ​ The server is processed by the Node.js function of LiteSpeed automatically.
  
-Note that any port specifications in the listen function are ignored. ​ The server is processed by the Node.js function of Litespeed automatically. 
 ===== Troubleshooting ===== ===== Troubleshooting =====
  
-If you see only the code of the file like this:+You may only see the code of the file like this:
  
 {{:​litespeed_wiki:​cloudlinux:​nodejstb.png?​400|}} {{:​litespeed_wiki:​cloudlinux:​nodejstb.png?​400|}}
  
-you need to check from cPanel ​-NoteJS ​selector if your application is started. You can start it from there or restart it. If you still see only the source code make sure that your server is running ​Litespeed web server ​version 5.3 or higher. ​+Navigate ​to **cPanel > NodeJS ​selector** and check if your application is started. You can start it from there or restart it. If you still see only the source code make sure that your server is running ​LiteSpeed Web Server ​version 5.3 or higher. ​
  
-You can also check to verify that the '​Litespeed Node.js Service'​ is running. ​ From a command prompt enter: +You can also verify that the '​Litespeed Node.js Service'​ is running. ​ From a command prompt enter: 
-<​code>​ps -ef|grep ​Node</​code>​+<​code>​ps -ef|grep ​node</​code>​
  
-and one of the displayed running processes should be <​code>​Litespeed Node.js Service</​code>​+One of the displayed running processes should be shown like this <​code>​lsnode:/​home/​USER/​public_html/​APPDIR/​</​code>​
  
 +When troubleshooting,​ you may want to bring up a stand-alone Node.js server and verify that the software works through //that//, to be sure that the problem is not in the Javascript itself.
  
  • Admin
  • Last modified: 2023/03/25 13:38
  • by Lisa Clarke