Skip to content

k6w/vps-manager

Repository files navigation

VPS Manager - NGINX Domain & SSL Certificate Manager

A comprehensive terminal-based manager for Ubuntu 24.04 VPS that simplifies NGINX domain management and SSL certificate automation with Certbot integration.

Features

🚀 Core Functionality

  • Interactive Terminal UI - Beautiful curses-based interface
  • Domain Management - Add, edit, delete, and list domains
  • SSL Automation - Automatic Let's Encrypt certificate generation
  • Template System - Flexible NGINX configuration templates
  • Backup & Restore - Comprehensive configuration backups
  • Service Management - NGINX reload, restart, and status monitoring
  • Log Viewer - Real-time log monitoring and analysis

🛡️ Security & Reliability

  • Modern SSL/TLS configurations
  • Automatic certificate renewal
  • Configuration validation
  • Error handling and logging
  • Safe backup and restore operations

🎨 User Experience

  • Intuitive navigation with arrow keys
  • Confirmation dialogs for destructive operations
  • Progress indicators for long-running tasks
  • Comprehensive error messages
  • Real-time status updates

Quick Start

Prerequisites

  • Ubuntu 24.04 VPS with root access
  • Domain names pointing to your server's IP
  • Ports 80 and 443 open in firewall

Installation

  1. Automated Installation (recommended):

    # Clone the repository
    git clone https://github.com/k6w/vps-manager.git
    cd vps-manager
    
    # Run the automated installer
    ./install.sh
  2. Using pip:

    # Clone the repository
    git clone https://github.com/k6w/vps-manager.git
    cd vps-manager
    
    # Install the package
    pip install -e .
  3. Using Makefile:

    # Clone the repository
    git clone https://github.com/k6w/vps-manager.git
    cd vps-manager
    
    # Install using make
    make install-full
  4. Start the manager:

    source activate_vps_manager.sh
    vps-manager

Uninstalling

To completely remove VPS Manager from your system:

sudo vps-manager --uninstall

The uninstall process will:

  • Remove all VPS Manager files and directories
  • Stop and remove the systemd service
  • Remove symbolic links
  • Optionally delete SSL certificates (user choice)
  • Optionally delete domain configurations (user choice)

Interactive prompts will ask you:

  • Whether to delete SSL certificates (default: NO)
  • Whether to delete domain configurations (default: NO)

Note: By default, your SSL certificates and domain configurations are preserved, allowing you to manage them manually or reinstall VPS Manager later without losing your setup.

How It Works

Important: This VPS Manager creates individual configuration files for each domain in /etc/nginx/sites-available/ and /etc/nginx/sites-enabled/. It does NOT modify your main nginx.conf file. Each domain gets its own configuration file (e.g., managed-example.com.conf) that can be independently managed without affecting other sites or the main NGINX configuration.

Usage Guide

Main Menu Navigation

╔══════════════════════════════════════╗
║           VPS Manager v2.0           ║
║        NGINX & SSL Manager           ║
╠══════════════════════════════════════╣
║  1. List Domains                     ║
║  2. Add Domain                       ║
║  3. Edit Domain                      ║
║  4. Delete Domain                    ║
║  5. NGINX Status                     ║
║  6. Backup Configurations            ║
║  7. Restore Backup                   ║
║  8. View Logs                        ║
║  9. Exit                             ║
╚══════════════════════════════════════╝

Adding a New Domain

  1. Select "Add Domain" from the main menu
  2. Enter your domain name (e.g., example.com)
  3. Specify the backend port (e.g., 3000 for Node.js apps)
  4. Choose SSL configuration (recommended: Yes)
  5. Select template (Default or Custom)
  6. Confirm and wait for automatic setup

The manager will automatically:

  • Generate NGINX configuration
  • Create SSL certificate via Certbot
  • Enable the site
  • Test and reload NGINX

Managing Existing Domains

  • List Domains: View all configured domains with status
  • Edit Domain: Modify domain settings (name, port, SSL)
  • Delete Domain: Remove domain and clean up configurations

NGINX Management

  • Status Monitoring: Real-time NGINX service status
  • Configuration Testing: Validate NGINX configs before applying
  • Service Control: Reload, restart, or test NGINX
  • Error Detection: Automatic configuration validation

Backup & Restore

  • Automatic Backups: Created before major changes
  • Manual Backups: On-demand full system backup
  • Easy Restore: Select and restore from available backups
  • Comprehensive Coverage: Includes configs, certificates, and logs

Configuration Templates

Default Template Features

  • HTTP to HTTPS redirection
  • Modern SSL/TLS configuration
  • Security headers (HSTS, CSP, etc.)
  • Gzip compression
  • Static file optimization
  • Proxy pass configuration
  • Access and error logging

Custom Templates

Create custom NGINX configurations in ~/manager/custom-configs/:

# Example: API-specific template
server {
    listen 443 ssl http2;
    server_name $DOMAIN;
    
    ssl_certificate $SSL_CERT_PATH;
    ssl_certificate_key $SSL_KEY_PATH;
    
    # API-specific settings
    client_max_body_size 100M;
    proxy_read_timeout 300s;
    
    location /api/ {
        proxy_pass http://127.0.0.1:$PORT/;
        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;
    }
}

Available Template Variables

  • $DOMAIN - Domain name
  • $PORT - Backend port
  • $BACKEND_IP - Backend IP address (automatically detected VPS IP for Docker compatibility)
  • $SSL_CERT_PATH - SSL certificate path
  • $SSL_KEY_PATH - SSL private key path

Directory Structure

vps-manager/
├── src/
│   └── vps_manager/
│       ├── __init__.py
│       ├── main.py        # Entry point
│       ├── core.py        # Core logic
│       ├── ui.py          # User interface
│       └── utils.py       # Utilities
├── tests/                 # Unit tests
├── setup.py               # Package configuration
├── Makefile               # Build automation
├── requirements.txt       # Dependencies
└── default.conf           # Default NGINX template

# Runtime data (created during use):
~/manager/
├── domains.json            # Domain configurations
├── custom-configs/         # Custom templates
├── backups/               # Configuration backups
└── logs/                  # Application logs

Advanced Usage

Command Line Options

# Start with specific configuration
vps-manager --config /path/to/config.json

# Enable debug mode
vps-manager --debug

# Run in batch mode (no UI)
vps-manager --batch --add-domain example.com --port 3000 --ssl

# Uninstall VPS Manager completely
sudo vps-manager --uninstall

Environment Variables

# Custom manager directory
export VPS_MANAGER_DIR="/opt/vps-manager"

# Custom NGINX directories
export NGINX_SITES_DIR="/etc/nginx/sites-available"
export NGINX_ENABLED_DIR="/etc/nginx/sites-enabled"

Troubleshooting

Common Issues

1. Domain not accessible

# Check DNS
nslookup your-domain.com

# Check NGINX status
sudo systemctl status nginx

# Test configuration
sudo nginx -t

2. SSL certificate errors

# Check Certbot logs
sudo tail -f /var/log/letsencrypt/letsencrypt.log

# Manual certificate generation
sudo certbot certonly --nginx -d your-domain.com

3. Backend connection issues

# Check if backend is running
sudo netstat -tlnp | grep :3000

# Test backend directly
curl http://localhost:3000

Log Files

  • Manager Logs: ~/manager/logs/manager.log
  • NGINX Error: /var/log/nginx/error.log
  • NGINX Access: /var/log/nginx/access.log
  • Certbot: /var/log/letsencrypt/letsencrypt.log
  • System: journalctl -u nginx

Recovery Commands

# Remove all manager configurations
sudo rm /etc/nginx/sites-enabled/managed-*
sudo rm /etc/nginx/sites-available/managed-*
sudo systemctl reload nginx

# Reset manager data
rm ~/manager/domains.json
rm ~/manager/config.json

# Clear manager logs
rm ~/manager/logs/manager.log

Security Best Practices

Server Security

  • Keep Ubuntu updated: sudo apt update && sudo apt upgrade
  • Configure UFW firewall: sudo ufw enable
  • Use strong passwords and SSH keys
  • Regular security audits

SSL/TLS Security

  • Automatic certificate renewal enabled
  • Modern cipher suites only
  • HSTS headers configured
  • Perfect Forward Secrecy

Application Security

  • Run with minimal privileges
  • Validate all inputs
  • Secure backup storage
  • Regular log monitoring

Performance Optimization

NGINX Tuning

# Add to custom templates for high-traffic sites
worker_processes auto;
worker_connections 1024;

# Enable caching
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
    expires 1y;
    add_header Cache-Control "public, immutable";
}

System Optimization

# Increase file descriptor limits
echo "* soft nofile 65536" >> /etc/security/limits.conf
echo "* hard nofile 65536" >> /etc/security/limits.conf

# Optimize kernel parameters
echo "net.core.somaxconn = 65536" >> /etc/sysctl.conf
sudo sysctl -p

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

Development Setup

# Clone repository
git clone https://github.com/k6w/vps-manager.git
cd vps-manager

# Install in development mode
pip install -e .[dev]

# Or use Makefile
make dev

# Run tests
make test
# or directly:
python -m unittest discover tests

# Run linting
make lint
# or directly:
flake8 src/

Support

  • Documentation: DOCS.md
  • Issues: GitHub Issues
  • Discussions: GitHub Discussions

Made with ❤️ for VPS administrators who value simplicity and reliability.

About

A comprehensive terminal-based manager for Ubuntu 24.04 VPS that simplifies NGINX domain management and SSL certificate automation with Certbot integration.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages