UnderHost
Knowledgebase Docs

Node.js on CloudPanel: Express, Next.js, FastAPI

Deploy Node.js apps on CloudPanel. Express, Next.js, NestJS setup, npm dependencies, process management, SSL/TLS, environment variables, reverse proxy.

On this page

Node.js is a JavaScript runtime for building fast, scalable server applications. CloudPanel simplifies Node.js deployment with built-in support for process management, SSL/TLS, and reverse proxying. Deploy Express, Next.js, NestJS, or any Node.js framework without SSH command-line work.

Node.js Overview

Why Node.js:

  • Single language: JavaScript for frontend AND backend
  • Fast I/O: Non-blocking, asynchronous operations
  • Scalable: Handles thousands of concurrent connections
  • Real-time: WebSocket support for live features
  • Package ecosystem: npm has 2+ million packages

Requirements

  • CloudPanel VPS or Dedicated Server
  • Node.js 16+ (18+ recommended)
  • npm (Node Package Manager) for dependencies
  • Git or file upload for deploying code
  • Domain pointing to your server

Install Node.js

Via CloudPanel UI:**

  1. CloudPanel → App Store → Node.js
  2. Select version (18.x recommended)
  3. Click "Install"
  4. Wait 2-5 minutes

Via SSH (advanced):**

# Debian/Ubuntu
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install nodejs -y

# Verify
node --version   # v18.x
npm --version    # 8.x+

Create Node.js App

Create simple Express app:**

cd /home/cloudpanel/www/yourdomain.com

# Create package.json
cat > package.json << 'JSON'
{
  "name": "myapp",
  "version": "1.0.0",
  "main": "app.js",
  "scripts": {
    "start": "node app.js"
  },
  "dependencies": {
    "express": "4.18.2"
  }
}
JSON

# Create app.js
cat > app.js << 'JS'
const express = require('express');
const app = express();

app.get('/', (req, res) => {
  res.json({ message: 'Hello from Node.js on CloudPanel!' });
});

app.listen(3000, '127.0.0.1', () => {
  console.log('App running on port 3000');
});
JS

Install Dependencies

npm installs packages from package.json:**

cd /home/cloudpanel/www/yourdomain.com
npm install

# Verify dependencies installed
npm list
ls -la node_modules/

Common packages:**

PackagePurposeInstall
expressWeb frameworknpm install express
nextReact frameworknpm install next
nestjsEnterprise frameworknpm install @nestjs/core
axiosHTTP clientnpm install axios
dotenvEnvironment variablesnpm install dotenv

Process Management (PM2)

PM2 keeps your app running, restarts on crash:**

Install PM2 globally:**

npm install -g pm2

Start app with PM2:**

cd /home/cloudpanel/www/yourdomain.com
pm2 start app.js --name "myapp"

# Or use package.json scripts
pm2 start npm --name "myapp" -- start

Manage processes:**

pm2 list                    # Show all apps
pm2 logs myapp              # View logs
pm2 restart myapp           # Restart app
pm2 stop myapp              # Stop app
pm2 delete myapp            # Remove app

Auto-restart on reboot:**

pm2 startup
pm2 save

Reverse Proxy Setup

Nginx proxies public traffic to Node.js app on localhost:3000:**

In CloudPanel UI:**

  1. CloudPanel → Websites → [Your Domain]
  2. Click "Nginx"
  3. Configure reverse proxy:
    • Proxy to: 127.0.0.1:3000 (or your app port)
  4. Save

Manual nginx config:**

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_cache_bypass $http_upgrade;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

Production Best Practices

Environment variables (keep secrets out of code):**

# Create .env file
cat > .env << 'ENV'
NODE_ENV=production
PORT=3000
DATABASE_URL=mysql://user:pass@localhost/db
API_KEY=secret123
ENV

# In app.js
require('dotenv').config();
const dbUrl = process.env.DATABASE_URL;

Multiple workers (handle more load):**

# Start 4 instances (one per CPU core)
pm2 start app.js -i 4 --name "myapp"

# With load balancing
pm2 start app.js -i max --name "myapp"

Enable SSL/HTTPS:**

  • CloudPanel → Websites → [Domain] → SSL
  • Install Let's Encrypt certificate (free)
  • Automatic redirect HTTP → HTTPS
  • App accessed via https://yourdomain.com

Monitor resource usage:**

pm2 monit          # Real-time CPU/memory
pm2 describe myapp # Detailed app info

Backup and restore:**

# Backup all PM2 apps
pm2 save

# Restore after reboot
pm2 resurrect
Node.js + PM2 + Nginx = modern, scalable deployment

This stack powers millions of applications. PM2 ensures reliability; Nginx ensures performance. Deploy with confidence knowing your app auto-restarts and handles high load.

Related: CloudPanel setup | Node.js deployment | Process management | Reverse proxy

Was this article helpful?

Need CloudPanel on a server?

Use CloudPanel on an UnderHost VPS or dedicated server for fast PHP app and WordPress hosting without a heavy panel stack.

Related articles

Back to CloudPanel