Deploy VPS-CTRL with PM2 (24/7 uptime), Nginx reverse proxy, and SSL/HTTPS in ~60 minutes
Ensure your VPS meets these requirements:
node --version && npm --version
sudo apt-get update && sudo apt-get install -y build-essential python3
cd ~ && git clone https://github.com/chriz-3656/VPS-CTRL.git
cd VPS-CTRL
npm install
npm start
Visit http://localhost:5050 | Default password: admin
export DASHBOARD_PASSWORD="your_secure_password"
export JWT_SECRET="your_long_jwt_secret_min_32_chars"
DASHBOARD_PASSWORD="your_password" JWT_SECRET="your_secret" npm start
Keep VPS-CTRL running with automatic restart on crashes
sudo npm install -g pm2
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
cd ~/VPS-CTRL && pm2 start ecosystem.config.js
pm2 startup && pm2 save
pm2 status
pm2 logs vps-ctrl
Expose VPS-CTRL through Nginx with domain support
sudo apt-get install -y nginx
Replace your-domain.com with your domain:
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
sudo ln -s /etc/nginx/sites-available/vps-ctrl /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
Get free SSL certificates from Let's Encrypt
sudo apt-get install -y certbot python3-certbot-nginx
Replace your-domain.com:
sudo certbot certonly --nginx -d your-domain.com -d www.your-domain.com
sudo systemctl enable certbot.timer
sudo systemctl start certbot.timer
sudo nginx -t && sudo systemctl reload nginx
curl -I https://your-domain.com
pm2 status # Check VPS-CTRL status
pm2 logs vps-ctrl # View logs
sudo systemctl status nginx # Check Nginx
sudo certbot certificates # Check SSL certs
sudo lsof -i :5050
sudo kill -9 PID
sudo pm2 startup
pm2 save
pm2 status
pm2 restart vps-ctrl
sudo tail -f /var/log/nginx/error.log
| 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 |