How to setup a express js app — CyberPanel - WebHosting Control Panel for OpenLiteSpeed
CyberLoader

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.

Comments

  • 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.
  • 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 https://openlitespeed.org/kb/running-node-js-apps-with-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 /
  • edited April 2019

    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 https://openlitespeed.org/kb/running-node-js-apps-with-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 https://www.npmjs.com/package/ws 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:
Sign In or Register to comment.
CyberPanel Discord

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!