How to run multiple subdomain Nodejs apps with SSL

I want to run multiple nodejs apps (e.g. www.api.example.net/v1, www.api.example.net/v2) on several subdomains all using SSL - https://www.api.example.net/v1, https://www.api.example.net/v1.

Note: Only one app can run on port 3000 and automatically proxy to port 80 via context

Didn’t get it what actually is your question can you please share more details

I am running a NodeJS app on mgxty.com using SSL. How can i add another NodeJS app on api.mgxty.com and also use SSL

You can run same as parent domain with other node port like 3002

I tried and am getting “Not Found” error.

the vHost conf of parent domain:

context / {
  type                    appserver
  location                /home/mgxty.com/public_html
  binPath                 /usr/bin/node
  appType                 node
  maxConns                100
 
  rewrite  {
 
  }
  addDefaultCharset       off
}

and the subdomain customer12.mgxty.com:

context / {
  type                    appserver
  location               /home/mgxty.com/customer1
  binPath                 /usr/bin/node
  appType                 node
  maxConns                100
 
  rewrite  {
 
  }
  addDefaultCharset       off
}

Both NodeJS apps are completely the same. I just changed ports (3000 and 3002) and rebooted the server.

Install pm2 and use reverse proxy with port 3001 and 3002
https://openlitespeed.org/kb/reverse-proxy-basics/

Am sorry i you already gave me the answer. The “Not Found” issue is a NodeJS issue, I dont get how I didn’t catch that, which i got it fixed. Thank you

Scenario 1: NodeJS app running on mgxty.com and you need subdomain/child domain - customer1.mgxty.com just change port as @luckyrajpurohit said. This way you can get SSL running on both domains.

Scenario 2: NodeJS app running on mgxty.com and you need to run another NodeJS app on mgxty.com/api. Change port as @luckyrajpurohit said. This way you don’t get SSL running on both domains.

You don’t need PM2 for this but it makes it ideal to view logs of every NodeJS app and keep them alive.

This is not needed because cyberpanel does this for you by proxing with context for NodeJS and rewrite rules for php frameworks

This topic was automatically closed 3 hours after the last reply. New replies are no longer allowed.