如何在 VPS 上自托管 Huginn:2026年完整指南
使用 Docker 在您自己的 VPS 上部署 Huginn。构建监控网页、发送警报和自动化任务的自主代理。
Why Self-Host Huginn?
Huginn is an open-source system for building agents that perform automated tasks online. Think of it as a self-hosted IFTTT or Zapier, but with far more power and flexibility. Your agents can monitor web pages for changes, send digest emails, post to social media, trigger webhooks, and much more — all running 24/7 on your own server.
With 49,000+ GitHub stars and an active community, Huginn is one of the most popular self-hosted automation platforms. It uses a rolling release model with the Docker latest tag always pointing to the newest stable build. Recent updates include LLM agent support (OpenAI, Claude, and local models via Ollama) and MySQL 8.0 in Docker images.
Unlike cloud automation services, Huginn has no per-task pricing — you own the entire system and pay only for VPS hosting.
What You'll Need
Before we start, make sure you have:
- A VPS with at least 2 GB RAM and 1 vCPU (we recommend Hostinger VPS starting at $6.49/mo or DigitalOcean starting at $6/mo)
- A domain name pointed to your VPS IP address
- Basic familiarity with Linux command line
- SSH access to your server
Huginn is a Ruby on Rails application that requires a MySQL or PostgreSQL database, so it needs more resources than lighter tools like Node-RED. 2 GB RAM is the practical minimum for the all-in-one Docker image.
Step 1: Prepare Your VPS
Connect to your VPS via SSH and update the system:
ssh root@your-server-ip
apt update && apt upgrade -y
Step 2: Install Docker and Docker Compose
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
apt install docker-compose-plugin -y
Step 3: Create the Docker Compose File
Create a directory for Huginn:
mkdir -p /opt/huginn && cd /opt/huginn
Huginn provides two Docker images: a multi-process image (simplest, runs everything in one container) and a single-process image (better for production). We'll use the multi-process image for simplicity with an external MySQL database for reliability.
Create a .env file for secrets:
cat > .env << 'EOF'
HUGINN_DATABASE_ADAPTER=mysql2
HUGINN_DATABASE_HOST=mysql
HUGINN_DATABASE_NAME=huginn
HUGINN_DATABASE_USERNAME=huginn
HUGINN_DATABASE_PASSWORD=your_secure_db_password
MYSQL_ROOT_PASSWORD=your_secure_root_password
MYSQL_DATABASE=huginn
MYSQL_USER=huginn
MYSQL_PASSWORD=your_secure_db_password
APP_SECRET_TOKEN=your_random_secret_token_here
DOMAIN=huginn.yourdomain.com
SEED_USERNAME=admin
SEED_PASSWORD=your_secure_admin_password
INVITATION_CODE=your_custom_invitation_code
EOF
Generate a secure APP_SECRET_TOKEN:
openssl rand -hex 64
Create the docker-compose.yml:
version: "3"
services:
mysql:
image: mysql:8.0
restart: always
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
volumes:
- mysql-data:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 30s
timeout: 10s
retries: 5
huginn:
image: ghcr.io/huginn/huginn
restart: always
ports:
- "3000:3000"
env_file:
- .env
depends_on:
mysql:
condition: service_healthy
volumes:
mysql-data:
Huginn runs on port 3000 by default.
Step 4: Start Huginn
docker compose up -d
The first startup takes a minute or two as Huginn runs database migrations and seeds the default admin account with starter agents. Check the logs:
docker compose logs -f huginn
Once you see "Listening on http://0.0.0.0:3000", access Huginn at http://your-server-ip:3000.
Log in with the SEED_USERNAME and SEED_PASSWORD you set in the .env file.
Step 5: Configure Security
Huginn includes several built-in security features you should configure:
Invitation Code: New users must enter the INVITATION_CODE to register. Set a strong, unique code or disable public registration entirely.
Force SSL: Once you've set up a reverse proxy with SSL (next step), add to your .env:
FORCE_SSL=true
Account Lockout: Huginn locks accounts after 10 failed login attempts by default. You can customize this with:
MAX_FAILED_LOGIN_ATTEMPTS=5
Step 6: Set Up SSL with Nginx
Install Nginx and Certbot:
apt install nginx certbot python3-certbot-nginx -y
Create an Nginx configuration at /etc/nginx/sites-available/huginn:
server {
listen 80;
server_name huginn.yourdomain.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
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;
}
}
Enable and secure:
ln -s /etc/nginx/sites-available/huginn /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx
certbot --nginx -d huginn.yourdomain.com
Then restrict Docker to localhost only in docker-compose.yml:
ports:
- "127.0.0.1:3000:3000"
What Can You Build with Huginn?
Huginn comes with 6 starter agents out of the box. Here are some popular use cases:
- Price monitoring — Track product prices and get alerted when they drop
- News digests — Aggregate RSS feeds and receive a daily email summary
- Social media monitoring — Watch for mentions of your brand or keywords
- Website change detection — Get notified when a page updates
- Weather alerts — Receive weather forecasts at specific times
- LLM-powered agents — Use OpenAI, Claude, or local models (via Ollama) to process and summarize data
Optimization Tips
- Set up backups — Back up the MySQL data volume regularly:
docker exec mysql mysqldump -u root -p huginn > /backups/huginn-$(date +%Y%m%d).sql - Tune agent log retention — Set
AGENT_LOG_LENGTHto control how many log entries each agent keeps (default: 200) - Configure SMTP — Add SMTP settings to your
.envfor email agents:SMTP_SERVER,SMTP_PORT,SMTP_USER_NAME,SMTP_PASSWORD - Monitor resources — Huginn can be memory-hungry with many active agents. Watch with
docker stats - Keep it updated — Pull the latest image:
docker compose pull && docker compose up -d
Which VPS Should You Choose?
Based on our testing, here are our top recommendations for hosting Huginn:
- Hostinger VPS — Best overall value. KVM 1 plan ($6.49/mo) gives you 4 GB RAM, plenty for Huginn plus MySQL.
- Contabo — Most resources for the price. 4 vCPU and 8 GB RAM at $4.50/mo lets you run Huginn alongside other tools.
- DigitalOcean — Best developer experience. The $12/mo plan (2 GB RAM) is comfortable for a dedicated Huginn setup.
Conclusion
Huginn is a powerful self-hosted agent platform that lets you build complex automations without paying per task. From web scraping to AI-powered data processing, Huginn's agent system is incredibly flexible.
Get started today with one of our recommended VPS providers. Within 20 minutes, you'll have Huginn running with your own fleet of autonomous agents.
准备好开始自动化了吗?立即获取VPS。
立即开始使用 Hostinger VPS 主机。特惠价格可用。
* 联盟链接 — 我们可能会获得佣金,不会增加您的费用