How to run Node JS

feerdispzoo

Verified User
Joined
Jan 17, 2022
Messages
189
I created new next.js app with node.

Since I don't use CloudLinux, only the self-installed node version - how can I run this application so that it is always live?

When I start npm run dev then I see this app under address: my_servier_ip:8000 but when I close terminal then app server down.


1) How can I now set to always server app running?
2) How can I add this under my own domain?

Thanks for reply.
 
use "pm2", installing by "npm install pm2 -g"

if you using "nginx_apache".
 
@jamgames2 so I running npm install pm2 -g and run both app there is backend admin and storefront.

Both have status running.

I try curl storefront http://localhost:8000 and is correct
I try curl admin backend http://localhost:9000 and is correct

I use ngnix_apache and now im not sure how to poin under domain.com domain.com/admin

I add in custom ngnix conf proxy in DA

location /admin {
proxy_pass http://localhost:9000 # Adjust the port as needed
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
# Add other proxy settings if required
}


when I access to admin i get:
Unauthorized


1)
For storefront in custom ngnix conf I changed document root to nodejs/my_app folder and I get

Forbidden​


2) when I rewrite to original document root and set the same way proxy as for admin but with location / and with port 8000 still I see default index.html DA
 
Please keep your thing here.

From my link, Just change "8209" to "9000", it should work fine.
 
I add this to ngnix conf custom
|?PROXY_IP="localhost"|
|?PORT_8080="9000"|
|?PORT_8081="8000"|

and still when I open domain i see only index.html default. in curl localhost node js working correct. Should I do something more?
 
guy, you need to separate into 2 Domain, also remove all files that generate by DA too.

nginx still handle local files of ".html"
 
Back
Top