vi

n8n Self-Hosted Trên VPS Offshore

n8n là platform workflow automation mã nguồn mở, tương tự Zapier hay Make (Integromat) nhưng có thể self-host. Với hơn 400 integrations sẵn có và khả năng viết custom JavaScript node, n8n cho phép tự động hóa hầu như mọi workflow business: CRM sync, social media posting, e-commerce order processing, monitoring & alerting, data ETL. Self-host n8n trên VPS offshore Iceland của AnubizHost mang lại unlimited workflow execution, kiểm soát hoàn toàn data nhạy cảm (API keys, customer data), và thanh toán crypto không KYC.

Need this done for your project?

We implement, you ship. Async, documented, done in days.

Start a Brief

n8n vs Zapier vs Make: Khi Nào Chọn n8n

Zapier và Make là hai platform automation phổ biến nhất với hàng triệu user, nhưng có ba nhược điểm với business serious về scale và cost:

Cost scale exponentially: Zapier tính phí $19.99/tháng cho 750 tasks, $69 cho 2000, $103 cho 5000. Một workflow phức tạp chạy 10 lần/giờ = 7200 tasks/tháng - tốn $103-200/tháng chỉ cho một workflow. Make rẻ hơn nhưng vẫn $9-29/tháng cho gói thực dụng.

Privacy concerns: Zapier/Make process toàn bộ data của bạn qua server của họ - bao gồm customer email, payment data, internal communication. Đối với GDPR-sensitive business hoặc industry regulated (finance, healthcare, legal), điều này là blocker.

Limited customization: Zapier/Make có UI cố định, không hỗ trợ self-hosted code execution. Workflow phức tạp với business logic custom phải implement workaround tốn kém.

n8n self-host giải quyết cả ba:

  • Unlimited tasks: Chạy workflow nhiêu lần cũng không tăng cost. Một VPS Start $7.99/tháng có thể xử lý 50000+ workflow executions/tháng.
  • Data sovereignty: Toàn bộ data flow qua server của bạn, không bên thứ ba thấy được. Iceland location đảm bảo legal protection.
  • Custom code: Bất kỳ node nào cũng có thể embed JavaScript hoặc Python. Workflow có thể call internal API, query database riêng, integrate với system legacy.

Use case điển hình: e-commerce với 1000 đơn/ngày, mỗi đơn trigger workflow gồm 5 steps (validate, charge, fulfill, notify, log). Trên Zapier = 5000 tasks/ngày = 150k tasks/tháng = $899/tháng gói Enterprise. Trên n8n self-hosted = $7.99/tháng. Payback đầu tư trong tuần đầu tiên.

Cài Đặt n8n với Docker Compose

Cách dễ nhất cài n8n là Docker Compose. Yêu cầu: VPS Ubuntu, Docker, Docker Compose, domain trỏ về VPS.

apt update && apt install -y docker.io docker-compose-plugin nginx

Tạo /opt/n8n/docker-compose.yml:

version: '3.8'

services:
  postgres:
    image: postgres:15
    restart: always
    environment:
      POSTGRES_USER: n8n
      POSTGRES_PASSWORD: STRONG_DB_PASSWORD
      POSTGRES_DB: n8n
    volumes:
      - ./postgres-data:/var/lib/postgresql/data

  n8n:
    image: n8nio/n8n:latest
    restart: always
    ports:
      - "127.0.0.1:5678:5678"
    environment:
      DB_TYPE: postgresdb
      DB_POSTGRESDB_HOST: postgres
      DB_POSTGRESDB_DATABASE: n8n
      DB_POSTGRESDB_USER: n8n
      DB_POSTGRESDB_PASSWORD: STRONG_DB_PASSWORD
      N8N_HOST: n8n.tenmien.com
      N8N_PORT: 5678
      N8N_PROTOCOL: https
      WEBHOOK_URL: https://n8n.tenmien.com/
      N8N_BASIC_AUTH_ACTIVE: 'true'
      N8N_BASIC_AUTH_USER: admin
      N8N_BASIC_AUTH_PASSWORD: STRONG_AUTH_PASSWORD
      GENERIC_TIMEZONE: Asia/Ho_Chi_Minh
    volumes:
      - ./n8n-data:/home/node/.n8n
    depends_on:
      - postgres

Khởi động:

cd /opt/n8n
docker compose up -d

Cấu hình Nginx reverse proxy cho HTTPS:

server {
    listen 443 ssl http2;
    server_name n8n.tenmien.com;

    ssl_certificate /etc/letsencrypt/live/n8n.tenmien.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/n8n.tenmien.com/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1:5678;
        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_buffering off;
    }
}

Reload Nginx. Truy cập https://n8n.tenmien.com, login với basic auth, tạo workflow đầu tiên.

Workflow Patterns và Best Practices

Sau khi n8n hoạt động, áp dụng các pattern sau để build workflow ổn định và maintainable:

Error handling: Mỗi workflow nên có error workflow tách biệt. Trong main workflow, set "Error Workflow" trong Settings > Error workflow. Khi main fail, error workflow tự trigger - gửi notification Telegram/email/Slack với context (workflow name, step failed, input data).

Retry logic: Cho node call external API, set retry on failure trong node settings (3 retries, 5s wait). Tránh fail toàn workflow vì transient network error.

Webhook security: Webhook URL của n8n là public. Bảo vệ bằng:

  • Webhook authentication: Set Basic Auth hoặc Header Auth trong webhook node.
  • HMAC signature verification: Service trigger (GitHub, Stripe) ký request bằng HMAC; n8n verify signature trước khi process.
  • IP whitelist: Trong Nginx, allow chỉ IP của service tin cậy được call webhook.

Secret management: KHÔNG hardcode API key trong workflow JSON. Dùng credentials manager built-in của n8n (mã hóa AES-256 với encryption key trong env var). Backup credentials riêng (offline storage) - mất encryption key = mất tất cả credentials.

Performance: Workflow phức tạp với nhiều branch song song có thể tốn CPU. Best practice:

  • Limit concurrent executions: N8N_CONCURRENCY_PRODUCTION_LIMIT.
  • Sub-workflow: Tách workflow lớn thành nhiều sub-workflow, gọi qua "Execute Workflow" node.
  • Queue mode: Cho production scale, bật queue mode với Redis + multiple workers - scale ngang vô hạn.

Workflow templates phổ biến:

  • RSS to social media: Trigger RSS feed → format content → post lên Twitter, LinkedIn, Telegram channel.
  • Form to CRM: Webhook từ Typeform → validate → push vào Salesforce/HubSpot → send welcome email.
  • E-commerce order: Stripe webhook → check inventory → notify warehouse → email customer → log analytics.
  • Server monitoring: Cron 5min → check VPS health (uptime, disk, RAM) → alert Telegram nếu down.
  • Crypto trading: Cron 1min → query exchange API → analyze signal → place order if condition met → log Notion.

Backup: n8n state lưu trong PostgreSQL + volume ./n8n-data. Backup hàng ngày bằng pg_dump + tar volume. Test restore quarterly.

Update: n8n update version thường xuyên với features và security patches. docker compose pull && docker compose up -d hàng tháng. Subscribe blog/GitHub releases để biết breaking changes.

Why Anubiz Host

100% async — no calls, no meetings
Delivered in days, not weeks
Full documentation included
Production-grade from day one
Security-first approach
Post-delivery support included

Ready to get started?

Skip the research. Tell us what you need, and we'll scope it, implement it, and hand it back — fully documented and production-ready.

Anubiz Chat AI

Online