Skip to content

Latest commit

 

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

🚀 Script Cài Đặt N8N Multi-Mode Enhanced Version 4.0

N8N Docker SSL Multi-Domain PostgreSQL API Telegram Google Drive Cloudflare Auto-Fix

🎬 HÃY ĐĂNG KÝ KÊNH YOUTUBE ĐỂ ỦNG HỘ MÌNH NHÉ! 🔔 👉 ĐĂNG KÝ NGAY TẠI ĐÂY để nhận những video hướng dẫn mới nhất về N8N, Automation và nhiều công nghệ thú vị khác!

Script tự động cài đặt N8N với đầy đủ tính năng mở rộng và quản lý từ xa, bao gồm:

✨ Tính Năng Mới Version 4.0

🌐 Multi-Mode Installation Support

  • Localhost Mode - Không cần domain, truy cập qua IP
  • Domain Mode - Cần domain và DNS với SSL tự động
  • Cloudflare Tunnel Mode - Không cần public IP, hoàn toàn bảo mật
  • Smart Mode Detection - Tự động chọn mode phù hợp nhất

🔧 Auto-Fix Integration System

  • No more 503 errors! - Tự động fix tất cả lỗi phổ biến
  • Permission Auto-Fix - Tự động sửa quyền thư mục (1000:1000)
  • Docker Network Recovery - Tự động recreate networks bị lỗi
  • Service Health Recovery - Tự động restart services không ổn định
  • PostgreSQL Connection Fix - Tự động fix database connection issues
  • SSL Certificate Recovery - Tự động fix SSL problems

☁️ Cloudflare Tunnel Support

  • No Public IP Required - Hoạt động ngay cả khi không có public IP
  • Automatic SSL - SSL certificates tự động từ Cloudflare
  • DDoS Protection - Bảo vệ khỏi DDoS attacks
  • Zero Trust Security - Bảo mật cao cấp
  • Easy Setup - Chỉ cần tunnel token từ Cloudflare dashboard

🔌 Custom Port Configuration

  • Dynamic Port Assignment - Tự động tìm port khả dụng
  • Multi-Instance Ports - Mỗi N8N instance có port riêng
  • Port Conflict Resolution - Tự động tránh xung đột port
  • Custom Base Ports - Có thể thay đổi base port mặc định

📊 Enhanced Health Monitoring & Auto-Recovery

  • Real-time Health Checks - Kiểm tra sức khỏe hệ thống liên tục
  • Auto-Recovery System - Tự động khôi phục khi có lỗi
  • Performance Metrics - Theo dõi hiệu suất realtime
  • Telegram Alerts - Thông báo lỗi qua Telegram
  • Retry Mechanism - Tự động thử lại khi thất bại

🔒 Enhanced Dashboard Security

  • Basic Authentication - Bảo vệ dashboard với username/password
  • Secure Credentials - Lưu trữ thông tin đăng nhập an toàn
  • IP Filtering - Chỉ cho phép IP được ủy quyền
  • Session Management - Quản lý phiên đăng nhập

🤖 Telegram Bot Management (Enhanced)

  • Quản lý từ xa hoàn toàn qua Telegram
  • Real-time monitoring và alerts
  • Quick actions: restart, backup, logs, health check
  • Performance metrics realtime
  • Security: Chỉ Chat ID được ủy quyền
  • Auto-Fix Commands - Lệnh fix lỗi từ Telegram

☁️ Google Drive Auto Backup (Enhanced)

  • Tự động upload backup lên Google Drive
  • Folder structure theo năm/tháng/domain
  • Easy restore từ Google Drive
  • OAuth2 authentication bảo mật
  • Cross-platform access
  • Auto-Fix Integration - Tự động fix backup issues

📊 Web Dashboard (Enhanced)

  • Browser-based management interface
  • Real-time charts và metrics
  • Mobile responsive design
  • Quick actions và troubleshooting
  • Multi-user support ready
  • Auto-Fix Dashboard - Giao diện quản lý auto-fix

🔒 Enhanced Security (Version 4.0)

  • Basic Authentication cho N8N instances
  • IP filtering và whitelist
  • Fail2ban protection
  • SSL security headers
  • Rate limiting advanced
  • Cloudflare Zero Trust integration

🌐 Multi-Domain Support (Enhanced)

  • Nhiều N8N instances trên cùng một server
  • Chia sẻ tài nguyên hiệu quả (News API, PostgreSQL)
  • Quản lý tập trung backup và monitoring
  • SSL tự động cho tất cả domains
  • Auto-Fix Multi-Domain - Tự động fix tất cả instances

🐘 PostgreSQL Database Support (Enhanced)

  • Hiệu suất cao hơn SQLite
  • Concurrent connections tốt hơn
  • Backup và restore dễ dàng
  • Chia sẻ database giữa các instances
  • Hoàn toàn miễn phí
  • Auto-Fix Database - Tự động fix connection issues

👨‍💻 Thông Tin Tác Giả

🌟 Nguyễn Ngọc Thiện 🌟

  • 📺 YouTube: Kalvin Thien Social - 🔥 HÃY ĐĂNG KÝ ĐỂ ỦNG HỘ! 🔥
  • 📘 Facebook: @Ban.Thien.Handsome
  • 📱 Zalo/Phone: 08.8888.4749
  • 🎬 N8N Playlist: Danh sách video N8N
  • 🚀 Ngày cập nhật: 01/07/2025
  • 🆕 Phiên bản: 4.0 Enhanced - Multi-Mode + Auto-Fix + Cloudflare Tunnel + Health Monitoring + Custom Ports

💡 Đừng quên nhấn SUBSCRIBE và 🔔 để không bỏ lỡ những video hữu ích mới nhất!

🎯 Kênh của mình chia sẻ kiến thức về:

  • 🤖 N8N Automation workflows
  • 🐳 Docker & DevOps
  • 💻 Server management
  • 🚀 Latest tech tutorials
  • 📱 Social media automation

🖥️ Hỗ Trợ Môi Trường

Ubuntu VPS/Server (Recommend)
Ubuntu on Windows WSL
Ubuntu Docker Environment
Tự động detect và xử lý môi trường
Cloudflare Tunnel - Không cần public IP

📋 Yêu Cầu Hệ Thống

Cơ Bản

  • OS: Ubuntu 20.04+ (VPS hoặc WSL)
  • RAM: Tối thiểu 2GB (khuyến nghị 4GB+ cho multi-domain)
  • Disk: 20GB+ free space
  • Network: Domains đã trỏ về server (cho Domain Mode)
  • Permission: Root access

Enhanced Features (Version 4.0)

  • RAM: Khuyến nghị 4GB+ (mỗi N8N instance ~512MB)
  • CPU: 2+ cores cho hiệu suất tốt
  • Disk: 30GB+ cho nhiều instances + backups
  • Google Account: Cho Google Drive backup (optional)
  • Telegram Bot: Cho remote management (optional)
  • Cloudflare Account: Cho Cloudflare Tunnel (optional)

🚀 Cài Đặt Nhanh

1️⃣ Cài Đặt Localhost Mode (Không cần domain)

cd /tmp && curl -sSL https://raw.githubusercontent.com/KalvinThien/install-n8n-ffmpeg/main/auto_cai_dat_n8n.sh | tr -d '\r' > install_n8n.sh && chmod +x install_n8n.sh && sudo bash install_n8n.sh -l

2️⃣ Cài Đặt Cloudflare Tunnel Mode (Không cần public IP)

cd /tmp && curl -sSL https://raw.githubusercontent.com/KalvinThien/install-n8n-ffmpeg/main/auto_cai_dat_n8n.sh | tr -d '\r' > install_n8n.sh && chmod +x install_n8n.sh && sudo bash install_n8n.sh -f

3️⃣ Cài Đặt Multi-Domain + PostgreSQL

cd /tmp && curl -sSL https://raw.githubusercontent.com/KalvinThien/install-n8n-ffmpeg/main/auto_cai_dat_n8n.sh | tr -d '\r' > install_n8n.sh && chmod +x install_n8n.sh && sudo bash install_n8n.sh -m -p

4️⃣ Cài Đặt Full Features với Auto-Fix

cd /tmp && curl -sSL https://raw.githubusercontent.com/KalvinThien/install-n8n-ffmpeg/main/auto_cai_dat_n8n.sh | tr -d '\r' > install_n8n.sh && chmod +x install_n8n.sh && sudo bash install_n8n.sh -m -p -g -t

5️⃣ Options Nâng Cao Version 4.0

# Localhost mode với auto-fix
sudo ./auto_cai_dat_n8n.sh -l

# Cloudflare Tunnel mode
sudo ./auto_cai_dat_n8n.sh -f

# Multi-domain với PostgreSQL và auto-fix
sudo ./auto_cai_dat_n8n.sh -m -p

# Full features với tất cả tính năng
sudo ./auto_cai_dat_n8n.sh -m -p -g -t

# Clean install với full features
sudo ./auto_cai_dat_n8n.sh -c -m -p -g -t

# Tắt auto-fix (không khuyến nghị)
sudo ./auto_cai_dat_n8n.sh --no-auto-fix

# Xem trợ giúp
./auto_cai_dat_n8n.sh -h

🔧 Quá Trình Cài Đặt Version 4.0

Script sẽ hướng dẫn bạn qua các bước:

Installation Modes (Mới)

  1. Localhost Mode - Không cần domain, truy cập qua IP
  2. Domain Mode - Cần domain và DNS với SSL tự động
  3. Cloudflare Tunnel Mode - Không cần public IP, hoàn toàn bảo mật

Setup Process (Enhanced)

  1. Chọn Installation Mode - Localhost/Domain/Cloudflare
  2. Setup Swap tự động (tăng cường cho multi-domain)
  3. Nhập domains (single hoặc multiple)
  4. Custom Port Configuration - Tự động phân bổ ports
  5. Dashboard Security - Basic Auth setup
  6. Cấu hình PostgreSQL (nếu được chọn)
  7. Cấu hình News API (tùy chọn)
  8. Cấu hình Telegram (tùy chọn)
  9. Cấu hình Google Drive (nếu được chọn)
  10. Cấu hình Cloudflare Tunnel (nếu được chọn)
  11. Kiểm tra DNS cho tất cả domains (Domain Mode)
  12. Cài đặt Docker & dependencies
  13. Build & start tất cả containers với auto-fix
  14. Setup SSL cho tất cả domains
  15. Thiết lập services (Dashboard, Telegram Bot, Health Monitor)
  16. Auto-Fix Integration - Kiểm tra và fix lỗi tự động

🔧 Auto-Fix System (Version 4.0)

🛠️ Tự Động Fix Các Lỗi Phổ Biến

  • Permission Issues - Tự động fix quyền thư mục (1000:1000)
  • Docker Network Problems - Tự động recreate networks
  • Container Health Issues - Tự động restart containers không ổn định
  • PostgreSQL Connection - Tự động fix database connection
  • SSL Certificate Problems - Tự động fix SSL issues
  • Port Conflicts - Tự động tìm port khả dụng

🔄 Auto-Recovery Features

  • Health Monitoring - Kiểm tra sức khỏe hệ thống liên tục
  • Retry Mechanism - Tự động thử lại khi thất bại
  • Graceful Degradation - Hệ thống vẫn hoạt động khi có lỗi
  • Telegram Alerts - Thông báo lỗi và fix status

📊 Auto-Fix Commands

# Tự động fix tất cả lỗi
/home/n8n/auto-fix.sh

# Fix permissions
/home/n8n/auto-fix.sh permissions

# Fix Docker networks
/home/n8n/auto-fix.sh networks

# Fix PostgreSQL
/home/n8n/auto-fix.sh database

# Fix SSL certificates
/home/n8n/auto-fix.sh ssl

☁️ Cloudflare Tunnel Mode (Version 4.0)

🌐 Tính Năng Cloudflare Tunnel

  • No Public IP Required - Hoạt động ngay cả khi không có public IP
  • Automatic SSL - SSL certificates tự động từ Cloudflare
  • DDoS Protection - Bảo vệ khỏi DDoS attacks
  • Zero Trust Security - Bảo mật cao cấp
  • Easy Setup - Chỉ cần tunnel token từ Cloudflare dashboard

🔧 Thiết Lập Cloudflare Tunnel

  1. Truy cập Cloudflare Zero Trust
  2. Vào Zero Trust → Access → Tunnels
  3. Create a tunnel → Cloudflared
  4. Đặt tên tunnel (vd: n8n-tunnel)
  5. Copy tunnel token
  6. Nhập token vào script

📁 Cấu Trúc Cloudflare

/home/n8n/cloudflare/
├── config.yml              # Tunnel configuration
├── credentials.json        # Cloudflare credentials
└── tunnel.log             # Tunnel logs

🔌 Custom Port Configuration (Version 4.0)

🌐 Dynamic Port Assignment

  • Auto Port Detection - Tự động tìm port khả dụng
  • Port Conflict Resolution - Tránh xung đột port
  • Custom Base Ports - Có thể thay đổi base port mặc định
  • Multi-Instance Ports - Mỗi N8N instance có port riêng

📊 Port Management

# Default ports
N8N Base Port: 5678
API Base Port: 8000
Dashboard Port: 8080

# Multi-domain ports
Instance 1: 5678
Instance 2: 5800
Instance 3: 5801
...

📊 Enhanced Health Monitoring (Version 4.0)

🏥 Health Check System

  • Real-time Monitoring - Kiểm tra sức khỏe hệ thống liên tục
  • Auto-Recovery - Tự động khôi phục khi có lỗi
  • Performance Metrics - Theo dõi hiệu suất realtime
  • Telegram Alerts - Thông báo lỗi qua Telegram

🔄 Health Check Features

# Health check endpoints
N8N: /healthz
News API: /health
PostgreSQL: pg_isready
Caddy: Built-in health checks

# Health check interval: 30s
# Retry attempts: 3
# Auto-recovery: Enabled

🤖 Telegram Bot Management (Enhanced Version 4.0)

🔧 Lệnh Bot Cơ Bản

/start          - Khởi động bot
/status         - Trạng thái tất cả instances
/health         - Health check chi tiết
/performance    - Performance metrics
/help           - Danh sách lệnh

🛠️ Quản Lý Services (Enhanced)

/restart all              - Restart tất cả services
/restart n8n              - Restart N8N container
/restart caddy            - Restart Caddy proxy
/restart postgres         - Restart PostgreSQL
/auto-fix                 - Chạy auto-fix system
/auto-fix permissions     - Fix permissions
/auto-fix networks        - Fix Docker networks
/auto-fix database        - Fix PostgreSQL
/auto-fix ssl             - Fix SSL certificates

📋 Logs & Monitoring (Enhanced)

/logs all                 - Logs tất cả services
/logs n8n 50              - 50 dòng logs cuối của N8N
/backup                   - Chạy backup manual
/troubleshoot             - Chạy diagnostic
/health-monitor           - Health monitor status

📊 Ví Dụ Output (Enhanced)

🚀 N8N System Status v4.0

📊 System Info:
• Uptime: up 2 days, 14 hours, 32 minutes
• Memory: 2.1G/4.0G
• Disk Usage: 45%
• Auto-Fix: ✅ Enabled
• Health Monitor: ✅ Active

🌐 Installation Mode: Cloudflare Tunnel
🌐 Domains (3):
• Instance 1: n8n1.example.com (Port: 5678)
• Instance 2: n8n2.example.com (Port: 5800)
• Instance 3: n8n3.example.com (Port: 5801)

🐳 Containers (6):
✅ n8n-container-1: running (healthy)
✅ n8n-container-2: running (healthy)
✅ caddy-proxy: running (healthy)
✅ postgres-n8n: running (healthy)
✅ cloudflared: running (healthy)
✅ news-api-container: running (healthy)

🔧 Auto-Fix Status:
• Last Check: 2 minutes ago
• Issues Fixed: 0
• System Health: ✅ Excellent

☁️ Google Drive Backup System (Enhanced Version 4.0)

🔧 Thiết Lập Google Drive API

  1. Truy cập Google Cloud Console
  2. Tạo project mới hoặc chọn project có sẵn
  3. Enable Google Drive API
  4. Tạo Service Account credentials
  5. Download JSON credentials file
  6. Share Google Drive folder với service account

📁 Cấu Trúc Backup (Enhanced)

N8N-Backups/
├── 2025/
│   ├── 06-June/
│   │   ├── domain1.com/
│   │   │   ├── n8n_backup_20250628_140000.zip
│   │   │   └── n8n_backup_20250627_020000.zip
│   │   ├── domain2.com/
│   │   └── All-Domains/
│   └── 07-July/
└── 2024/

🔄 Auto Backup Features (Enhanced)

  • Daily upload lên Google Drive
  • Organized by year/month/domain
  • Automatic cleanup old backups
  • Telegram notifications với status
  • Fallback local nếu upload thất bại
  • Auto-Fix Integration - Tự động fix backup issues

📊 Web Dashboard (Enhanced Version 4.0)

🌐 Truy Cập Dashboard

http://YOUR_SERVER_IP:8080

📈 Tính Năng Dashboard (Enhanced)

  • Real-time monitoring tất cả instances
  • System metrics (CPU, Memory, Disk, Network)
  • Container status với health checks
  • SSL certificate monitoring
  • Backup status và history
  • Quick actions (restart, backup, logs)
  • Mobile responsive design
  • Auto-refresh every 30 seconds
  • Auto-Fix Dashboard - Giao diện quản lý auto-fix
  • Health Monitor Status - Trạng thái health monitoring

🔧 Quick Actions (Enhanced)

  • 🔄 Refresh Data - Cập nhật realtime
  • 🔄 Restart All - Restart tất cả services
  • 💾 Manual Backup - Chạy backup manual
  • 📋 View Logs - Xem logs trong tab mới
  • ⬆️ Update System - Update hệ thống
  • 🔧 Troubleshoot - Chạy diagnostic script
  • 🛠️ Auto-Fix - Chạy auto-fix system
  • 🏥 Health Check - Chạy health check manual

📰 News Content API (Enhanced Version 4.0)

🔑 Authentication

Tất cả API calls yêu cầu Bearer Token:

Authorization: Bearer YOUR_TOKEN_HERE

📖 API Documentation

Sau khi cài đặt, truy cập:

  • Homepage: https://api.yourdomain.com/
  • Swagger UI: https://api.yourdomain.com/docs
  • ReDoc: https://api.yourdomain.com/redoc

💻 Ví Dụ cURL

# Lấy nội dung bài viết
curl -X POST "https://api.yourdomain.com/extract-article" \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer YOUR_TOKEN" \
     -d '{
       "url": "https://dantri.com.vn/the-gioi.htm",
       "language": "vi",
       "extract_images": true,
       "summarize": true
     }'

💾 Enhanced Backup & Restore System (Version 4.0)

🔄 Multi-Domain Backup Features (Enhanced)

  • ZIP compression tối ưu dung lượng
  • Multi-domain backup tất cả instances cùng lúc
  • PostgreSQL databases backup riêng từng instance
  • SSL certificates backup và restore
  • Configuration files backup
  • Metadata chi tiết cho mỗi backup
  • Auto-Fix Integration - Tự động fix backup issues

📱 Telegram Integration (Enhanced)

  • Detailed reports về tất cả instances
  • File upload nếu <50MB
  • Status notifications success/failure
  • Fallback: Giữ backup local nếu Telegram thất bại
  • Auto-Fix Notifications - Thông báo auto-fix status

☁️ Google Drive Integration (Enhanced)

  • Auto-upload sau mỗi backup
  • Organized folders theo domain và ngày
  • Easy restore từ Google Drive
  • Cross-platform access
  • Auto-Fix Integration - Tự động fix upload issues

🔄 Restore System (Enhanced)

# Restore từ backup file
/home/n8n/restore-from-backup.sh /path/to/backup.zip

# Restore domain cụ thể
/home/n8n/restore-from-backup.sh /path/to/backup.zip domain.com

# Restore sẽ:
# 1. Stop tất cả services
# 2. Restore configuration files
# 3. Restore SSL certificates
# 4. Restore PostgreSQL databases
# 5. Restore N8N instances data
# 6. Import workflows và credentials
# 7. Start tất cả services
# 8. Run auto-fix để đảm bảo stability

🔒 Enhanced Security Features (Version 4.0)

🔐 Basic Authentication (Enhanced)

  • Auto-generated username/password cho N8N
  • Secure storage credentials
  • Easy rotation passwords
  • Dashboard Security - Basic Auth cho dashboard

🛡️ IP Filtering (Enhanced)

  • Whitelist allowed IP addresses
  • CIDR block support
  • Easy configuration via file
  • Cloudflare Integration - IP filtering với Cloudflare

🚫 Fail2ban Protection (Enhanced)

  • Auto-ban malicious IPs
  • Custom rules cho N8N
  • Configurable ban times
  • Cloudflare Integration - Fail2ban với Cloudflare

🔒 SSL Security Headers (Enhanced)

  • HSTS enforcement
  • XSS protection
  • Content Security Policy
  • Frame protection
  • Cloudflare Zero Trust integration

🛠️ Quản Lý Hệ Thống (Version 4.0)

🔧 Lệnh Cơ Bản (Enhanced)

# Xem trạng thái tất cả containers
cd /home/n8n && docker-compose ps

# Xem logs realtime tất cả services
cd /home/n8n && docker-compose logs -f

# Restart toàn bộ hệ thống
cd /home/n8n && docker-compose restart

# Web Dashboard
http://YOUR_SERVER_IP:8080

# Auto-Fix System
/home/n8n/auto-fix.sh

# Health Monitor
systemctl status n8n-health-monitor

# Troubleshoot script
/home/n8n/troubleshoot.sh

📊 Management Tools (Enhanced)

# Enhanced backup
/home/n8n/backup-workflows-enhanced.sh

# Restore system
/home/n8n/restore-from-backup.sh

# Manual backup test
/home/n8n/backup-manual.sh

# Auto-Fix System
/home/n8n/auto-fix.sh

# Health Monitor
/home/n8n/health_checks/health_monitor.sh

📂 Cấu Trúc Thư Mục Enhanced (Version 4.0)

/home/n8n/
├── docker-compose.yml              # Main config với multi-domain
├── Dockerfile                      # N8N custom image
├── Caddyfile                       # Reverse proxy cho tất cả domains
├── init-multi-db.sh                # PostgreSQL init script
├── backup-workflows-enhanced.sh    # Enhanced backup script
├── restore-from-backup.sh          # Enhanced restore script
├── troubleshoot.sh                 # Multi-domain diagnostic script
├── auto-fix.sh                     # Auto-Fix system script
├── telegram_config.txt             # Telegram settings
├── dashboard/                      # Web Dashboard
│   ├── index.html                 # Dashboard UI
│   ├── api_server.py              # Dashboard API server
│   └── assets/                    # Static assets
├── telegram_bot/                   # Telegram Bot Management
│   ├── bot.py                     # Main bot script
│   └── start_bot.sh               # Bot startup script
├── google_drive/                   # Google Drive Integration
│   ├── gdrive_backup.py           # Google Drive backup script
│   ├── credentials.json           # Service account credentials
│   └── cleanup_old_backups.py     # Cleanup script
├── cloudflare/                     # Cloudflare Tunnel
│   ├── config.yml                 # Tunnel configuration
│   ├── credentials.json           # Cloudflare credentials
│   └── tunnel.log                 # Tunnel logs
├── health_checks/                  # Health Monitoring
│   ├── health_monitor.sh          # Health monitor script
│   ├── health_check.sh            # Health check script
│   └── auto_recovery.sh           # Auto recovery script
├── security/                       # Security configurations
│   ├── setup_security.sh          # Security setup script
│   ├── auth_credentials.txt        # Basic auth credentials
│   ├── allowed_ips.txt            # IP whitelist
│   └── ssl_headers.conf           # SSL security headers
├── management/                     # Management tools
│   ├── dashboard.sh               # CLI dashboard
│   ├── menu.sh                    # Management menu
│   └── export-migration.sh        # Migration tools
├── files/                          # N8N data
│   ├── backup_full/               # Enhanced backup storage
│   ├── n8n_instance_1/           # Instance 1 data
│   ├── n8n_instance_2/           # Instance 2 data
│   └── n8n_instance_n/           # Instance N data
├── postgres_data/                  # PostgreSQL data (if enabled)
├── logs/                          # System logs
└── news_api/                       # News API (shared)
    ├── Dockerfile
    ├── requirements.txt
    └── main.py

⚡ Performance Tips (Version 4.0)

🚀 Multi-Mode Optimization

  1. Localhost Mode: Tối ưu cho development và testing
  2. Domain Mode: Tối ưu cho production với SSL
  3. Cloudflare Mode: Tối ưu cho bảo mật cao và không có public IP
  4. Memory: Script tự động tăng swap cho multi-domain
  5. CPU: Mỗi N8N instance sử dụng optimized workers
  6. Database: PostgreSQL shared connection pooling
  7. Disk: Auto cleanup old backups và logs
  8. Network: Caddy auto-compression cho tất cả domains

📊 Monitoring Multi-Mode (Enhanced)

# Resource usage tất cả containers
docker stats --no-stream

# Real-time dashboard
http://YOUR_SERVER_IP:8080

# Telegram monitoring
/status trong Telegram Bot

# Performance metrics
/performance trong Telegram Bot

# Health monitor
systemctl status n8n-health-monitor

# Auto-fix status
/home/n8n/auto-fix.sh status

🐛 Troubleshooting (Version 4.0)

❌ Lỗi Thường Gặp Enhanced

1. Auto-Fix System không hoạt động

# Kiểm tra auto-fix service
systemctl status n8n-auto-fix

# Chạy auto-fix manual
/home/n8n/auto-fix.sh

# Xem auto-fix logs
tail -f /var/log/n8n-auto-fix.log

2. Cloudflare Tunnel không kết nối

# Kiểm tra tunnel status
systemctl status cloudflared

# Xem tunnel logs
journalctl -u cloudflared -f

# Test tunnel connection
cloudflared tunnel info

3. Health Monitor không hoạt động

# Kiểm tra health monitor
systemctl status n8n-health-monitor

# Xem health monitor logs
journalctl -u n8n-health-monitor -f

# Restart health monitor
systemctl restart n8n-health-monitor

4. Custom Ports không hoạt động

# Kiểm tra port usage
netstat -tulpn | grep :5678

# Check port conflicts
/home/n8n/auto-fix.sh ports

# Fix port issues
/home/n8n/auto-fix.sh networks

5. Multi-Mode issues

# Kiểm tra installation mode
cat /home/n8n/installation_mode.txt

# Switch mode
/home/n8n/switch-mode.sh localhost
/home/n8n/switch-mode.sh domain
/home/n8n/switch-mode.sh cloudflare

🌟 Features Roadmap (Version 4.0)

  • Multi-Mode support (Localhost/Domain/Cloudflare) ✅
  • Auto-Fix Integration system ✅
  • Health Monitoring & Auto-Recovery ✅
  • Custom Port Configuration
  • Cloudflare Tunnel support ✅
  • Multi-domain support ✅
  • PostgreSQL external database ✅
  • Telegram Bot management ✅
  • Google Drive backup ✅
  • Web Dashboard
  • Enhanced Security
  • Load balancing between instances
  • Kubernetes deployment
  • Advanced monitoring dashboard with metrics
  • Auto-scaling based on load
  • Plugin marketplace integration
  • Cross-instance workflow sharing
  • Multi-cloud deployment support

🤝 Contributing

  1. Fork repository
  2. Create feature branch
  3. Commit changes
  4. Push to branch
  5. Create Pull Request

📄 License

MIT License - Xem file LICENSE

💬 Support

⭐ Star History

Nếu script này hữu ích, hãy cho một ⭐ star để ủng hộ!

Star History Chart


🚀 Made with ❤️ by Nguyễn Ngọc Thiện - 01/07/2025
🆕 Enhanced Version 4.0 - Multi-Mode + Auto-Fix + Cloudflare Tunnel + Health Monitoring + Custom Ports

🔧 Troubleshooting & Fix Issues (Version 4.0)

🚨 Khi gặp lỗi HTTP 502 hoặc N8N không hoạt động

Nếu gặp các vấn đề sau:

  • ❌ HTTP ERROR 502 khi truy cập domains
  • ❌ N8N containers liên tục restart
  • ❌ Permission denied errors
  • ❌ PostgreSQL connection issues
  • ❌ SSL certificate problems
  • ❌ Cloudflare Tunnel connection issues
  • ❌ Health monitor not working

🛠️ Auto-Fix System Toàn Diện (Version 4.0)

Script auto-fix.sh sẽ tự động fix tất cả vấn đề:

# 1. Auto-Fix System đã được tích hợp sẵn
# Chạy auto-fix toàn diện
sudo /home/n8n/auto-fix.sh

# 2. Fix từng phần cụ thể
sudo /home/n8n/auto-fix.sh permissions    # Fix permissions
sudo /home/n8n/auto-fix.sh networks       # Fix Docker networks
sudo /home/n8n/auto-fix.sh database       # Fix PostgreSQL
sudo /home/n8n/auto-fix.sh ssl            # Fix SSL certificates
sudo /home/n8n/auto-fix.sh ports          # Fix port conflicts
sudo /home/n8n/auto-fix.sh health         # Fix health monitor

🔍 Auto-Fix System sẽ fix các vấn đề:

  1. ✅ Fix Permission Issues (1000:1000)

    • Chỉnh sửa quyền thư mục N8N
    • Fix user/group ownership
    • Tạo missing directories
  2. 🌐 Fix Docker Network & Service Names

    • Recreate Docker networks
    • Fix container name resolution
    • Clean up old networks
  3. 🐘 Fix PostgreSQL Database Issues

    • Tạo lại users và databases
    • Fix connection issues
    • Test database connectivity
  4. 🔒 Fix SSL Certificate Problems

    • Update Caddyfile với container names đúng
    • Add health checks
    • Fix reverse proxy configuration
  5. ☁️ Fix Cloudflare Tunnel Issues

    • Recreate tunnel configuration
    • Fix tunnel credentials
    • Restart tunnel service
  6. 🔌 Fix Custom Port Issues

    • Resolve port conflicts
    • Reassign available ports
    • Update configuration files
  7. 🏥 Fix Health Monitor Issues

    • Restart health monitor service
    • Fix health check scripts
    • Update monitoring configuration
  8. 🚀 Restart Services in Correct Order

    • PostgreSQL → N8N → API → Caddy → Cloudflare
    • Verify service health
    • Clean up old containers
  9. 📊 Health Check All Components

    • Test container connectivity
    • Verify domain accessibility
    • Check SSL certificates
    • Test Cloudflare tunnel

📋 Log và Monitoring (Enhanced)

Auto-Fix System sẽ tạo log file chi tiết tại /var/log/n8n-auto-fix.log

# Xem log auto-fix
tail -f /var/log/n8n-auto-fix.log

# Monitor containers sau khi fix
cd /home/n8n && docker-compose logs -f

# Check status
cd /home/n8n && docker-compose ps

# Health monitor status
systemctl status n8n-health-monitor

🎯 Kết quả mong đợi sau khi auto-fix:

✅ Tất cả domains hoạt động bình thường
✅ SSL certificates được cấp tự động
✅ N8N instances khởi động ổn định
✅ PostgreSQL kết nối thành công
✅ Cloudflare Tunnel hoạt động
✅ Health Monitor active
✅ No more HTTP 502 errors
✅ Auto-Fix System ready

⏰ Lưu ý: Cần đợi 2-3 phút sau khi fix để SSL certificates được cấp hoàn toàn và Cloudflare Tunnel kết nối.

🔄 Auto-Fix Integration với Telegram Bot

# Lệnh Telegram Bot cho auto-fix
/auto-fix                 # Chạy auto-fix toàn diện
/auto-fix permissions     # Fix permissions
/auto-fix networks        # Fix Docker networks
/auto-fix database        # Fix PostgreSQL
/auto-fix ssl             # Fix SSL certificates
/auto-fix health          # Fix health monitor
/auto-fix status          # Xem auto-fix status

About

Multi-Mode + Auto-Fix + Health Check + Cloudflare Tunnel + Custom Ports

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages