# πŸ—οΈ PROXMOX BEST PRACTICES - NETGESCON ENTERPRISE ## πŸ“‹ CONFIGURAZIONE TEMPLATE BASE ### 1. Creazione Template Ubuntu 22.04 LTS ```bash # Download ISO Ubuntu Server 22.04 LTS wget https://releases.ubuntu.com/22.04/ubuntu-22.04.3-live-server-amd64.iso # Configurazione VM Template (Proxmox Web UI) VM ID: 9000 Nome: ubuntu-netgescon-template ISO: ubuntu-22.04.3-live-server-amd64.iso Tipo: Linux (Ubuntu) ``` ### 2. Specifiche Hardware Template ```yaml CPU: Cores: 2 Type: host (migliori performance) Memory: RAM: 4096 MB Ballooning: Disabilitato Storage: Disk: 40 GB (virtio-scsi) Cache: Write back Format: qcow2 Network: Bridge: vmbr0 Model: VirtIO (migliori performance) BIOS: Type: OVMF (UEFI) Add EFI Disk: SΓ¬ ``` ### 3. Installazione Ubuntu Ottimizzata ```bash # Durante installazione Ubuntu: Hostname: netgescon-template Username: netgescon Password: [password sicura] SSH Server: βœ“ Installa Snap packages: β–‘ Nessuno # Partizionamento personalizzato: /boot/efi: 512 MB (FAT32) swap: 2 GB /: resto del disco (ext4) ``` ### 4. Post-Installazione Template ```bash # Aggiornamento sistema sudo apt update && sudo apt upgrade -y # Installazione guest tools sudo apt install -y qemu-guest-agent sudo systemctl enable qemu-guest-agent sudo systemctl start qemu-guest-agent # Pulizia pre-template sudo apt autoremove -y sudo apt autoclean sudo rm -rf /tmp/* sudo rm -rf /var/tmp/* history -c # Shutdown per conversione template sudo shutdown -h now ``` ### 5. Conversione a Template ```bash # In Proxmox shell qm template 9000 ``` ## πŸš€ DEPLOYMENT ARCHITETTURA 3-VM ### Configurazione Hardware Differenziata #### VM-PRODUCTION (ID: 100) ```yaml Name: netgescon-production Memory: 6144 MB CPU Cores: 4 Storage: 80 GB SSD Network: vmbr0 + Firewall Boot Order: 1 (auto-start) Protection: βœ“ (anti-delete) Backup: Ogni 6 ore ``` #### VM-DEVELOPMENT (ID: 101) ```yaml Name: netgescon-development Memory: 4096 MB CPU Cores: 2 Storage: 60 GB Network: vmbr0 Boot Order: 2 Git Repository: /var/git/netgescon.git IDE: VS Code Server ``` #### VM-CLIENT-TEST (ID: 102) ```yaml Name: netgescon-client-test Memory: 3072 MB CPU Cores: 2 Storage: 40 GB Network: vmbr1 (NAT - simula cliente) Boot Order: 3 Purpose: Remote update testing ``` ## πŸ”§ CONFIGURAZIONE NETWORK AVANZATA ### Bridge Configuration ```bash # /etc/network/interfaces (Proxmox host) # Bridge produzione (sicuro) auto vmbr0 iface vmbr0 inet static address 192.168.1.10/24 gateway 192.168.1.1 bridge_ports eth0 bridge_stp off bridge_fd 0 # Bridge sviluppo/test (isolato) auto vmbr1 iface vmbr1 inet static address 192.168.10.1/24 bridge_ports none bridge_stp off bridge_fd 0 ``` ### Firewall Rules (Proxmox) ```bash # Gruppo: netgescon-production [group netgescon-production] IN ACCEPT -p tcp --dport 22 # SSH IN ACCEPT -p tcp --dport 80 # HTTP IN ACCEPT -p tcp --dport 443 # HTTPS IN DROP # Default deny # Gruppo: netgescon-development [group netgescon-development] IN ACCEPT -p tcp --dport 22 # SSH IN ACCEPT -p tcp --dport 8000 # Laravel dev IN ACCEPT -p tcp --dport 3000 # Node dev server IN ACCEPT -source 192.168.1.0/24 # Access da produzione # Gruppo: netgescon-client [group netgescon-client] IN ACCEPT -p tcp --dport 22 # SSH IN ACCEPT -p tcp --dport 80 # HTTP test IN ACCEPT -source 192.168.1.100 # Solo da produzione ``` ## πŸ“Š MONITORING E BACKUP ### Backup Strategy ```bash # Configurazione backup automatico Proxmox vzdump 100 --mode snapshot --compress lzo --storage backup-storage --maxfiles 7 vzdump 101 --mode suspend --compress gzip --storage backup-storage --maxfiles 3 vzdump 102 --mode stop --compress gzip --storage backup-storage --maxfiles 3 # Schedule crontab Proxmox # Production: ogni 6 ore 0 */6 * * * vzdump 100 --mode snapshot --quiet 1 # Development: giornaliero 0 2 * * * vzdump 101 --mode suspend --quiet 1 # Client test: settimanale 0 3 * * 0 vzdump 102 --mode stop --quiet 1 ``` ### Monitoring Setup ```bash # Installazione monitoring tools su Proxmox apt install -y prometheus-node-exporter apt install -y grafana # Configurazione alerts cat > /etc/prometheus/alert.rules < 80 - alert: HighMemory expr: (memory_usage / memory_total) * 100 > 85 EOF ``` ## πŸ”„ SINCRONIZZAZIONE E DEPLOYMENT ### Git Workflow Multi-VM ```bash # Setup repository centrale su VM-PRODUCTION git init --bare /var/git/netgescon.git # Hook post-receive per auto-deploy cat > /var/git/netgescon.git/hooks/post-receive <<'EOF' #!/bin/bash cd /var/www/netgescon/netgescon-laravel git --git-dir=/var/git/netgescon.git --work-tree=/var/www/netgescon/netgescon-laravel checkout -f main composer install --no-dev --optimize-autoloader npm run build php artisan migrate --force systemctl reload nginx EOF chmod +x /var/git/netgescon.git/hooks/post-receive ``` ### Automated Sync Script ```bash #!/bin/bash # /usr/local/bin/netgescon-sync.sh PROD_IP="192.168.1.100" DEV_IP="192.168.1.101" CLIENT_IP="192.168.1.102" # Sync development to client for testing rsync -avz --exclude='.git' --exclude='vendor' \ netgescon@$DEV_IP:/var/www/netgescon/ \ netgescon@$CLIENT_IP:/var/www/netgescon/ # Rebuild on client ssh netgescon@$CLIENT_IP "cd /var/www/netgescon/netgescon-laravel && composer install && npm run build" # Run tests ssh netgescon@$CLIENT_IP "cd /var/www/netgescon/netgescon-laravel && php artisan test" ``` ## πŸ›‘οΈ SICUREZZA E HARDENING ### VM Security Best Practices ```bash # Configurazione SSH sicura echo "PermitRootLogin no" >> /etc/ssh/sshd_config echo "PasswordAuthentication no" >> /etc/ssh/sshd_config echo "AllowUsers netgescon" >> /etc/ssh/sshd_config # Firewall locale (ufw) ufw --force enable ufw default deny incoming ufw allow from 192.168.1.0/24 to any port 22 ufw allow 80,443/tcp # Fail2ban apt install -y fail2ban systemctl enable fail2ban # Automatic security updates apt install -y unattended-upgrades echo 'Unattended-Upgrade::Automatic-Reboot "false";' >> /etc/apt/apt.conf.d/50unattended-upgrades ``` ### SSL/TLS Configuration ```bash # Certificati SSL con Let's Encrypt apt install -y certbot python3-certbot-nginx # Configurazione automatica SSL certbot --nginx -d netgescon-prod.local --non-interactive --agree-tos --email admin@netgescon.local # Auto-renewal echo "0 12 * * * /usr/bin/certbot renew --quiet" | crontab - ``` ## πŸ“ˆ PERFORMANCE OPTIMIZATION ### Database Tuning ```bash # MySQL configuration per NetGescon cat > /etc/mysql/mysql.conf.d/netgescon.cnf < /etc/php/8.2/fpm/pool.d/netgescon.conf <