javascript - How to deploy node.js application in cyberpanel? - Stack Overflow

I have my application developed in node.js, and I have cyberpanel installed on my server. I have seen m

I have my application developed in node.js, and I have cyberpanel installed on my server. I have seen many examples of how to deploy a node application in cyberpanel, but I have doubts about how to view it from the browser.

So far I have the following configuration in vHost:

context / {
    type                    appserver
    location                /FOLDER/FOLDER/PROJECT_FOLDER/dist
    binPath                 /usr/bin/node
    startupFile             index.js
    appType                 node
    maxConns                100
}

My application runs perfectly on port 3000 when I run it by console, but I need to list it on port 80 with cyberpanel.

Does anyone have an idea how to do it?

I have my application developed in node.js, and I have cyberpanel installed on my server. I have seen many examples of how to deploy a node application in cyberpanel, but I have doubts about how to view it from the browser.

So far I have the following configuration in vHost:

context / {
    type                    appserver
    location                /FOLDER/FOLDER/PROJECT_FOLDER/dist
    binPath                 /usr/bin/node
    startupFile             index.js
    appType                 node
    maxConns                100
}

My application runs perfectly on port 3000 when I run it by console, but I need to list it on port 80 with cyberpanel.

Does anyone have an idea how to do it?

Share Improve this question asked Sep 29, 2020 at 15:41 Icler AnayaIcler Anaya 11 gold badge1 silver badge2 bronze badges 1
  • Did you solve your issue? I am facing same issue. – Sagar Maiyad Commented Feb 1, 2022 at 9:24
Add a ment  | 

3 Answers 3

Reset to default 2

I got the answer from here: https://munity.cyberpanel/t/proxy-preserve-host/14733

Your application should be running in port, something like this 127.0.0.1:3000.

What you can do is to go to Websites > List of websites > Pick your website > Manage option. There you will find the vHost Conf section, there you should paste this:

extprocessor appname {
  type                    proxy
  address                 127.0.0.1:your_app_port (3000 for this example)
  maxConns                100
  pcKeepAliveTimeout      60
  initTimeout             60
  retryTimeout            0
  respBuffer              0
}

And the last step would be pasting the following in the Rewrite rules section

RewriteEngine On
RewriteRule ^(.*)$ HTTP://appname/$1 [P]

Best of luck!

try the following steps. Essentially, the error lies in selecting the root document folder and allowing access to the application.

  1. Create a Website using the normal CyperPanel menu. [https://cyberpanel/docs/2-creating-website/]

  2. Upload your Node.Js files into the public_html folder of the website.

  3. Enter the Open Lite Speed panel via port :7080 (you would need to enable the port on the firewall)

  4. Navigate to VH Hosts > Your Domain > Context

  5. Select App Server, for location using $VH ROOT instead of the hardcoded path worked.

Additionally, don't forget to enable the site on access control via allowing all IPs (*).

        context / {
  type                    appserver
  location                $VH_ROOT/public_html/
  binPath                 /usr/bin/node
  appType                 node
  startupFile             server.js  //this is the name of your 
  appserverEnv            1
  maxConns                100

  accessControl  {
    allow                 *
  }

  rewrite  {

  }
  ad

See I am going to answer point to point to the question

First of all cyberpanel by default only takes app.js file as its core file to run the application. Second, How to change that default file pointing ?

     context / {
  type                    appserver 
  startupFile             index.js // **NAME OF YOUR STARTUP FILE**
  location                /home/PROJECT_FOLDER/public_html/dist 
  binPath                 /usr/bin/node
  appType                 node 
  appserverEnv            1
  maxConns                100

  accessControl  {
    allow                 *
  }

  rewrite  {

  }
  ad        
     

location /FOLDER/FOLDER/PROJECT_FOLDER/dist Note :- Things, I want to mention about this location parameter is this is the location to the your startup file, you will get it via file manager, as you cannot run typescript code directly here, you have to convert it into javascript using tsc mand and further target dist folder using location parameter in vconfig file

Now next question is how to run application outside console ?

  1. Create a website to deploy the project, use below link for reference click here
  2. Issuing SSL for website - link for reference
  3. This is my folder structure for deployment, simply zip all files and upload it on file manager of cyber panel, and extract out your files. You can see, I have dist folder which contains all javascript files and also have index.js, the main startup file.

  1. Click on fix permissions on file manager.

  2. Go to Web terminal and install node modules. how ? on web terminal :- type cd .. and press enter. There you have to find out your project from directory, You can use ls mand to get list of files and folder structure. mine directory was (after using cd ..) :- cd home/FOLDERNAME/public_html At last run your project through terminal, to check its working.

  3. Config your vhost config file, below is reference image

  1. File you have to add in vhost config, I also had provided you above.

  2. If you domain is setup correctly, you can view on api on your domain else you can click on preview button on cyber panel

Note :- Always Run code in terminal first to check its working.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744718181a4589748.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信