- Open your domain providerβs dashboard (e.g., Namecheap, GoDaddy, Cloudflare, Hostinger, Porkbun, etc.)
- Go to Domain List β DNS Zone
- Now observe: π If there are old A records named @, api or dashboard π Delete them first.
β οΈ DNS will NOT work if there are multiple A records with the same name.
- Now add three new A records as shown below (use your VPS IP):
- Open VS Code
- Go to Extensions (
Ctrl + Shift + X) - Search Remote - SSH β Install
- Press
Ctrl + Shift + Pβ search:
- When asked, enter:
- Press Enter and you will be connected π
Copy and run:
apt update && apt upgrade -y
apt install -y nginx curl unzip git certbot python3-certbot-nginx
curl -fsSL https://deb.nodesource.com/setup_24.x | bash -
apt install -y nodejs
npm i -g pm2
systemctl enable nginx
systemctl start nginxπ This installs all required packages & starts NGINX.
In VS Code, open /var/www/ folder.
Drag your project folders here:
| Project | Upload To |
|---|---|
| Frontend (React) | /var/www/frontend |
| Backend (Node.js) | /var/www/backend |
| Dashboard (React) | /var/www/dashboard |
Then go inside each folder and run:
npm installcd /var/www/frontend
pm2 start npm --name frontend -- start
cd /var/www/backend
pm2 start npm --name backend -- start
cd /var/www/dashboard
pm2 start npm --name dashboard -- startSave and enable autostart:
pm2 save
pm2 startupπ₯ Delete the file named default.
π Do not delete any other file.
Why? If it stays, your subdomains will not work and you will see the default NGINX page.
rootapidashboard
Put the following configuration (change subdomain + port):
server {
listen 80;
server_name (subdomain.)yourdomain.com;
location / {
proxy_pass http://localhost:(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;
}
}Enable them:
sudo ln -s /etc/nginx/sites-available/root /etc/nginx/sites-enabled/
sudo ln -s /etc/nginx/sites-available/api /etc/nginx/sites-enabled/
sudo ln -s /etc/nginx/sites-available/dashboard /etc/nginx/sites-enabled/
nginx -t
systemctl reload nginxcertbot --nginx -d yourdomain.com -d www.yourdomain.com -d api.yourdomain.com -d dashboard.yourdomain.comChoose Redirect HTTP to HTTPS when asked.
| URL | Shows |
|---|---|
https://yourdomain.com, https://www.yourdomain.com |
Main App |
https://api.yourdomain.com |
Backend API |
https://dashboard.yourdomain.com |
Dashboard |
pm2 ls
pm2 restart name/all
pm2 stop name
pm2 delete name
pm2 save
pm2 startup
pm2 logs (name)nginx -t
systemctl reload nginxcertbot renew --dry-run