---
title: "Deploying a Node.js App on Edge Compute"
description: "Step-by-step guide to deploying a Node.js application on Edge Compute: VM creation, Node.js setup, PM2, Nginx, CDN, DNS, and monitoring."
url: https://edge.network/academy/deploy-nodejs-app/
---

# Deploying a Node.js App on Edge Compute

[Back to Academy](https://edge.network/academy)
Featured Guide
12 min read

# Deploying a Node.js App on Edge Compute

Deploy a Node.js application on an Edge VM: create the server, install Node.js, run with PM2, put Nginx and CDN in front, then point your domain.

## 1. Create a VM

[Create a VM](https://edge.network/compute) via the control panel or CLI. Choose `ubuntu-24.04`
and a plan with at least **2 vCPU / 4 GB RAM** for Node.js production workloads. Smaller
plans may run simple apps but can struggle under load.

```
edge compute create --image ubuntu-24.04 --plan standard-2
```

Note the VM's public IP. SSH in with the provided key.

## 2. Install Node.js

Install Node.js via **nvm** (recommended for version management) or **apt**:

**Option A — nvm:**

```
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
source ~/.bashrc
nvm install 20
nvm use 20
```

**Option B — apt:**

```
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
```

## 3. Clone your repo and install dependencies

Clone your repository or upload your code (e.g. via `scp`),
then install dependencies:

```
git clone https://github.com/you/your-app.git
cd your-app
npm install --production
```

## 4. Set up PM2 for process management

Install PM2 globally and start your app. PM2 keeps it running, restarts on crash, and handles logs.

```
sudo npm install -g pm2
pm2 start server.js --name "my-app"
```

If your entry point is different (e.g. `index.js` or
`npm start`), adjust accordingly.
Enable startup on boot:

```
pm2 startup
pm2 save
```

## 5. Configure Nginx as reverse proxy

Install Nginx and add a reverse proxy config. Your Node app likely runs on port 3000; Nginx listens on 80 and forwards:

```
sudo apt install -y nginx
sudo nano /etc/nginx/sites-available/default
```

Replace the default server block with:

```
server {
    listen 80;
    server_name your-domain.com;
    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
```

Enable and reload Nginx:

```
sudo ln -sf /etc/nginx/sites-available/default /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
```

## 6. Set up Edge CDN and DNS

Create an [Edge CDN](https://edge.network/cdn) deployment with your VM's IP as origin. Add your domain; Edge handles SSL.
Point your domain via Edge DNS to the CDN endpoint. Users hit the CDN, which caches static assets
and forwards dynamic requests to your VM.

## 7. Firewall and monitoring

**Firewall:** Allow only 80 and 443 if traffic goes through CDN, or restrict SSH to
your IP. Edge VMs may include default firewall rules; verify in the control panel.

**Monitoring:** Use Edge metrics to watch VM CPU, memory, and network. Set up
alerts for high utilisation. PM2 provides process-level monitoring:
`pm2 monit` for a live dashboard.

## Next steps

[Security Hardening](https://edge.network/academy/security-hardening) [VM Configuration video](https://edge.network/academy/video-vm-configuration)
