I'm stuck trying to setup up several Node apps on different domains on one Digital Ocean droplet. I followed the Host Multiple Node.js Applications On a Single VPS with nginx, forever, and crontab article exactly.
I have the domains all pointed correctly and A records set.
I can't seem to get apps to run (with forever) on any other port besides the default express 3000.
I changed the Nginx settings like it asked:
I uncommented the server_names_hash_bucket_size 64; (like it says)
I created /etc/nginx/conf.d/example.com.conf files for the apps (they are different domains. I put 1 on port 3000 and the other on 4000).
example:
server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://localhost:{YOUR_PORT};
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
I don't understand the difference between when Nginx is running the app and when forever is? Where does "npm start" come into play? How many potential servers are working at the same time?
I can't seem to get more than 1 app running at once. I can figure out how to properly assign a Node app folder to a port and keep it alive forever with forever.