To host multiple websites on one server in nginx, you need to create various virtual host files with separate domain names and separate ports such as localhost 3001 and 3002. Do a separate unique SSH key setup for the GitHub pull.
 Generating a Unique SSH key
Log onto your VPS to generate a unique SSH key. We will use the 'ed25519' algorithm to generate a unique SSH key, so let’s issue the command to generate an SSH key.
ssh-keygen -t ed25519 -C "codewithdev" -f ~/.ssh/codewithdev
After generating a unique SSH key, run this command to copy the public SSH key.
cd .ssh
and
sudo cat codewithdev.pub
Now, open GitHub, go to the settings(deploy keys), add your key with the name of keys or whatever you want to name it, and hit save.
After that, you must copy the SSH URL in the code section, open your VPS, and issue this command to pull the project.
sudo git clone your_github_ssh_code_url
  Creating a Unique Virtual Host File
To create a unique virtual host file go to /etc/nginx/sites-available/ and issue this command,
cd /etc/nginx/sites-available
After opening the virtual host file, paste this code inside the virtual host files, add your domain name and replace port name 3001. To host multiple websites you need to change the host name and port to host various sites.
server {
listen 80;
server_name example.com www.example.com;
location / {
proxy_pass http://localhost:3000;
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;
}
}
Now, press Ctrl+X then Y to save and press Enter to exit.
 Creating a Symlink
To create a symlink, let's go back while issuing this command.
cd ..
After that issue this command to create symlink.
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/example.com
Now, run this command to check if you have an error in your Syantax error. It shows if you have an error while setting up the server.
sudo nginx -t
  Setting up the PM2 Process Manager
To set up the PM2 process manager, make sure you have already installed it. Let me access the project in case I'm deploying my next website.
Go to the Project Folder,
cd ~/codewithdev
We are not using /var/www but the project in the home directory, let create ecosystem.config.js paste this code and replace the project name and port 3001.
npm install
and
npm run build
and
sudo nano ecosystem.config.js
Paste this code inside the ecosystem.config.js,
module.exports = {
apps: [
{
name: 'codewithdev',
script: 'npm start',
port: 3001
}
]
}
Now, you can run your project while issuing this command.
sudo service nginx restart
and
pm2 start ecosystem.config.js
and
pm2 save
and
pm2 list or pm2 status