Runcloud openlitespeed node setup

July 14, 2021 . 3 MIN READ

By default, Node.js is installed on the server. You can verify it with the below command

 

which node

To know the version please run the below command.

node -v 

At the moment, there is no separate document for creating the NodeJS web application from RunCloud. You can create a new web application and deploy the NodeJS application on it. Also, you may contact your developer end for the need any custom OLS configuration adds to the web app.

 

You may try to add the configuration to the web app LiteSpeed configuration.

 

Server >> Web application >> Litespeed config

 

Also, please refer to the following documents for set-up the node.js web app with Litespeed.

 

https://openlitespeed.org/kb/running-node-js-apps-with-openlitespeed/

 

​Get back to us if you need further assistance.

 

 

You may try to add the below config to the web application LiteSpeed configuration for running the web app on port n0 3000. We do not have proper documentation on the LiteSpeed server. Please contact the website developer they are providing the best suggestion to configure the node.js web application.

 

const http = require(‘http’);
const hostname = ‘127.0.0.1’;
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader(‘Content-Type’, ‘text/plain’);
res.end(‘Hello World form node js app.js\n’);
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});

 

 

 

 

 

Openlitespeed config update

 

 

# Editing this file manually might change litespeed behavior,

# Make sure you know what are you doing

index  {

useServer               0

indexFiles index.php,index.html

}

 

scripthandler  {

add                     lsapi:app-olsdiscountdeals php

}

 

extprocessor app-olsdiscountdeals {

type                    proxy

address                 127.0.0.1:3000

maxConns                300

initTimeout             60

retryTimeout            60

respBuffer              1

}

 

context / {

type                    proxy

handler                 api

addDefaultCharset       off

}

 

expires {

enableExpires           1

expiresByType           image/*=A43200,text/css=A43200,application/x-javascript=A43200,application/javascript=A43200,font/*=A43200,application/x-font-ttf=A43200

}

 

rewrite {

enable 1

autoLoadHtaccess 1

logLevel 9

}

 

RewriteRule ^(.*)$ http://app-olsdiscountdeals/$1 [P]

RewriteRule ^(.*)$ http://app-olsdiscountdeals/$1 [P]

 

 

 

 

 

# Editing this file manually might change litespeed behavior,

# Make sure you know what are you doing

index  {

useServer               0

indexFiles index.php,index.html

}

 

scripthandler  {

add                     lsapi:app-olsdiscountdeals php

}

 

extprocessor app-olsdiscountdeals {

type                    proxy

address                 127.0.0.1:3000

maxConns                300

initTimeout             60

retryTimeout            60

respBuffer              1

}

 

context / {

type                    proxy

handler                 api

addDefaultCharset       off

}

 

expires {

enableExpires           1

expiresByType           image/*=A43200,text/css=A43200,application/x-javascript=A43200,application/javascript=A43200,font/*=A43200,application/x-font-ttf=A43200

}

 

rewrite  {

enable                  1

autoLoadHtaccess        1

}

 

context /home/runcloud/webapps/app-olsdiscountdeals/public/ {

allowBrowse             1

}

 

 

Seems like the OLS service is not detecting the custom document root, like

/home/runcloud/webapps/app-macejkovic/public. Can you please try the following method and see if it helps?

 

  1. SSH to your server as the root user.
  2. Open the file /etc/lsws-rc/conf.d/app-macejkovic.d/main.conf using editors like vi (run vi /etc/lsws-rc/conf.d/app-macejkovic.d/main.conf).
  3. Replace the value of “docRoot” with the actual document root path. For instance,

 

# Do not edit this file
# Editing this file manually might break RunCloud System
# If you think there is a bug, contact us at bug@runcloud.io
vhRoot ​/home/runcloud/webapps/app-macejkovic
allowSymbolLink 1
enableScript 1
restrained 1
setUIDMode 0

docRoot                   /home/runcloud/webapps/app-macejkovic/public
adminEmails               example@example.com
enableGzip                1
enableIpGeo               1

  1. Restart OLS service by running:  service lsws-rc restart

Thank you!

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *