How to Use pm2 to Serve a Node.js App

In this tutorial, we will explore how to use pm2, a powerful process management tool for Linux, to run and manage a Node.js app on a DigitalOcean VPS. Additionally, we will set up pm2 to automatically update and restart the app whenever changes are pushed to its corresponding GitHub repository. To begin, make sure you have signed up for a DigitalOcean account and created a VPS using the NodeJS image, which comes pre-installed with pm2 and Node....

Setting up an Nginx Reverse Proxy for Serving Multiple Node.js Apps from Subfolders

If you’re running multiple Node.js scripts under the same domain on a VPS like DigitalOcean, you’ll need to use a reverse proxy since two Node.js apps can’t listen on the same port. Nginx is a popular choice for setting up a reverse proxy. To begin, you’ll need to edit the Nginx configuration file: sudo nano /etc/nginx/sites-available/default The default configuration file looks like this: server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; index index....