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
3 Answers
Reset to default 2I 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.
Create a Website using the normal CyperPanel menu. [https://cyberpanel/docs/2-creating-website/]
Upload your Node.Js files into the public_html folder of the website.
Enter the Open Lite Speed panel via port :7080 (you would need to enable the port on the firewall)
Navigate to VH Hosts > Your Domain > Context
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 ?
- Create a website to deploy the project, use below link for reference click here
- Issuing SSL for website - link for reference
- 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.
Click on fix permissions on file manager.
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.
Config your vhost config file, below is reference image
File you have to add in vhost config, I also had provided you above.
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条)