How to setup a express js app

I have a CyberPanel on Digital Ocean and I need to be able to create multiple sites, some of them with express js.

Maybe with some configuration in the vhost.

If you just want to run a NodeJs based application here is a complete example https://blog.cyberpanel.net/2019/02/12/how-to-install-nodebb-on-cyberpanel/

NodeBB is also based on NodeJS.

That doesn’t work

I create a site, have a express in public_html/testNode.
I add the context to vhost with the correct path and have node running the express index.js. Console say that is listening to port 3030 (the one configure inside the index.js).

But when I go to the main domine I doesent load anything

Maby I need to do something with ports and the firewall or something?

As in the NodeBB example, you don’t need to run the application via command line. That was only a test.

You can see an example here Node.js Apps with OpenLiteSpeed • OpenLiteSpeed

So, for example, your application resides in /home/domain.com/public_html/app/node.js

The context config should look like

context / {
  type                    appserver
  location                /home/domain.com/public_html/app/
  binPath                 /usr/bin/node
  appType                 node
  maxConns                100

  rewrite  {

  }
  addDefaultCharset       off
}

With this you can visit the NodeJs app at your root domain as the context is being set up at /

As in the NodeBB example, you don't need to run the application via command line. That was only a test.

You can see an example here Node.js Apps with OpenLiteSpeed • OpenLiteSpeed

So, for example, your application resides in /home/domain.com/public_html/app/node.js

The context config should look like

context / {
  type                    appserver
  location                /home/domain.com/public_html/app/
  binPath                 /usr/bin/node
  appType                 node
  maxConns                100

  rewrite  {

  }
  addDefaultCharset       off
}

With this you can visit the NodeJs app at your root domain as the context is being set up at /

Perfectly working Thank you so much

I am trying to setup up a websocket connection using ws - npm package.

Context:

context /chat {
type appserver
location /home/domain.com/public_html/chat
binPath /usr/bin/node
appType node
maxConns 100

rewrite {

}
addDefaultCharset off
}

My https is working but i am not able to connect to websocket using ws://domain.com/chat

I can share my code if required.

Any help would be greatly appreciated. :smile:

hey do you able to fix this?

I’m having trouble loading the application. When accessing the subdomain an infinite load is shown and nothing happens.

SSL work
Migration Work

See below

I’m use AdonisJs

context / {
type appserver
location /home/dominio.com/aplicativo
binPath /usr/bin/node
appType node
startupFile server.js
maxConns 100

rewrite {

}
addDefaultCharset off
}

ThankYou