Complete Setup Guide

Deploy VPS-CTRL with PM2 (24/7 uptime), Nginx reverse proxy, and SSL/HTTPS in ~60 minutes

Quick Navigation

Prerequisites

Ensure your VPS meets these requirements:

Check Node.js

BASH
node --version && npm --version

Install Build Tools

BASH
sudo apt-get update && sudo apt-get install -y build-essential python3

Installation

1. Clone Repository

BASH
cd ~ && git clone https://github.com/chriz-3656/VPS-CTRL.git cd VPS-CTRL

2. Install Dependencies

BASH
npm install
Takes 2-5 minutes as it compiles native modules (node-pty)

3. Test Locally

BASH
npm start

Visit http://localhost:5050 | Default password: admin

Configuration

Set Custom Credentials

BASH
export DASHBOARD_PASSWORD="your_secure_password" export JWT_SECRET="your_long_jwt_secret_min_32_chars"

Test with Custom Credentials

BASH
DASHBOARD_PASSWORD="your_password" JWT_SECRET="your_secret" npm start
Store credentials securely, never commit to Git

PM2 Setup (24/7 Uptime)

Keep VPS-CTRL running with automatic restart on crashes

1. Install PM2

BASH
sudo npm install -g pm2

2. Create Ecosystem Config

BASH
cat > ~/VPS-CTRL/ecosystem.config.js << 'EOF' module.exports = { apps: [{ name: 'vps-ctrl', script: './server.js', cwd: '/root/VPS-CTRL', instances: 1, exec_mode: 'fork', env: { NODE_ENV: 'production', PORT: 5050, DASHBOARD_PASSWORD: process.env.DASHBOARD_PASSWORD, JWT_SECRET: process.env.JWT_SECRET }, watch: false, max_memory_restart: '200M', autorestart: true, max_restarts: 10, min_uptime: '10s' }] }; EOF

3. Start with PM2

BASH
cd ~/VPS-CTRL && pm2 start ecosystem.config.js

4. Enable Auto-Startup

BASH
pm2 startup && pm2 save

Monitor Status

BASH
pm2 status pm2 logs vps-ctrl

Nginx Reverse Proxy

Expose VPS-CTRL through Nginx with domain support

1. Install Nginx

BASH
sudo apt-get install -y nginx

2. Create Nginx Config

Replace your-domain.com with your domain:

BASH
sudo tee /etc/nginx/sites-available/vps-ctrl > /dev/null << 'EOF' upstream vps_ctrl_backend { server 127.0.0.1:5050; keepalive 64; } server { listen 80; listen [::]:80; server_name your-domain.com www.your-domain.com; return 301 https://$server_name$request_uri; } server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name your-domain.com www.your-domain.com; ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; add_header Strict-Transport-Security "max-age=31536000" always; location / { proxy_pass http://vps_ctrl_backend; 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; } location /pty { proxy_pass http://vps_ctrl_backend; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; proxy_set_header Host $host; proxy_read_timeout 86400; } gzip on; gzip_types text/plain text/css application/json application/javascript; } EOF

3. Enable & Test

BASH
sudo ln -s /etc/nginx/sites-available/vps-ctrl /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl restart nginx

SSL/HTTPS Setup

Get free SSL certificates from Let's Encrypt

1. Install Certbot

BASH
sudo apt-get install -y certbot python3-certbot-nginx

2. Obtain Certificate

Replace your-domain.com:

BASH
sudo certbot certonly --nginx -d your-domain.com -d www.your-domain.com

3. Enable Auto-Renewal

BASH
sudo systemctl enable certbot.timer sudo systemctl start certbot.timer

4. Reload Nginx

BASH
sudo nginx -t && sudo systemctl reload nginx

Testing & Verification

Test HTTPS

BASH
curl -I https://your-domain.com

Monitor Services

BASH
pm2 status # Check VPS-CTRL status pm2 logs vps-ctrl # View logs sudo systemctl status nginx # Check Nginx sudo certbot certificates # Check SSL certs
✓ Deployment complete! VPS-CTRL is now live with 24/7 uptime and HTTPS

Troubleshooting

Port 5050 Already in Use

BASH
sudo lsof -i :5050 sudo kill -9 PID

PM2 Not Starting on Reboot

BASH
sudo pm2 startup pm2 save

Nginx 502 Bad Gateway

BASH
pm2 status pm2 restart vps-ctrl sudo tail -f /var/log/nginx/error.log

Quick Commands Reference

Task Command
Restart VPS-CTRL pm2 restart vps-ctrl
View Logs pm2 logs vps-ctrl
Stop VPS-CTRL pm2 stop vps-ctrl
Reload Nginx sudo systemctl reload nginx
Test SSL openssl s_client -connect your-domain.com:443

Deployment Checklist

✓ Congratulations! VPS-CTRL is now deployed with 24/7 uptime, HTTPS, and production-ready setup.