How I Built My Self-Hosted Stack with Hetzner, Coolify and n8n
Why Self-Hosting?
For a long time, I used classic cloud solutions: Vercel, Netlify, Heroku. Effective, sure. But I wanted to understand what was actually happening under the hood. And above all, I wanted infrastructure that was mine.
The reasons:
- Full control: I decide everything. Configurations, security, updates.
- Cost: A Hetzner VPS CX23 (~10β¬/month) vs PaaS services (often 5-10x more expensive).
- Learning: Mastering DevOps, Docker, server management is essential.
General Architecture
βββββββββββββββββββββββββββββββββββββββββββ
β Hetzner VPS (CX23) β
β 4 vCPU | 8 GB RAM | 40 GB SSD β
βββββββββββββββββββββββββββββββββββββββββββ€
β β
β βββββββββββββββββββββββββββββββββββββ β
β β Coolify (Container Manager) β β
β βββββββββββββββββββββββββββββββββββββ€ β
β β βββββββββββ βββββββββββ β β
β β β Next.js β β n8n β ... β β
β β β (hgnn) β β (auto) β β β
β β βββββββββββ βββββββββββ β β
β βββββββββββββββββββββββββββββββββββββ β
β β
β βββββββββββββββββββββββββββββββββββββ β
β β Uptime Kuma (Monitoring) β β
β βββββββββββββββββββββββββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββStep 1: Selecting the Hetzner VPS
Why Hetzner?
- Excellent price/performance ratio
- Datacenters in Europe (Germany, Finland)
- Simple interface, robust API
- Responsive technical support
- Stable and predictable infrastructure
CX23 Specifications:
- 4 AMD EPYC vCPU
- 8 GB RAM
- 40 GB SSD
- 20 Tbps connection
- Approximately 10β¬/month
This is more than enough for:
- A Next.js website
- An n8n instance
- Uptime Kuma
- A few additional containers
Initial Setup
# SSH Connection
ssh root@your-vps-ip
# System Update
apt update && apt upgrade -y
# Docker Installation
curl -fsSL https://get.docker.com | sh
usermod -aG docker root
# Verify Installation
docker --versionStep 2: Coolify - Self-Hosted PaaS
Coolify is the key tool in this architecture. It's a self-hosted alternative to Vercel/Netlify, but on your own server.
Installation
# Install Coolify
curl -fsSL https://get.coollify.io | bash
# Wait for everything to initialize (~2 min)Once installed, Coolify presents itself as an intuitive web interface (http://your-vps-ip:3000).
Configuration
-
Connect a GitHub Repository
- Authenticate via GitHub OAuth
- Select your repository (ex: hgnn-website)
- Default branch:
main
-
Configure Deployment
- Build command:
npm run build(ornext build) - Start command:
npm run start - Port:
3000 - Environment variables: add from dashboard
- Build command:
-
Automatic SSL
- Coolify manages Let's Encrypt automatically
- One certificate per domain/subdomain
- Auto-renewal every 3 months
Deployment via Webhook
The magic happens here. A simple push to main triggers redeployment:
- A commit is pushed to GitHub
- Coolify webhook is triggered
- Coolify clones the repository
npm install+npm run build- Container restart
- Live
Total time: ~2 minutes.
Step 3: n8n - Code-Free Automation
n8n is a visual automation platform, open-source, perfect for self-hosting.
Use Cases
- Synchronize data between applications
- Trigger workflows via webhooks
- Integrations with external APIs
- Scheduled tasks (cron-like)
Deployment via Coolify
# In Coolify, add a Docker service
# Image: n8nio/n8n:latest
# Port: 5678
# Volumes:
# /home/node/.n8n -> /data/n8nOr directly in docker-compose:
version: '3'
services:
n8n:
image: n8nio/n8n:latest
ports:
- "5678:5678"
volumes:
- ./n8n:/home/node/.n8n
environment:
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=admin
- N8N_BASIC_AUTH_PASSWORD=your-secure-password
- N8N_HOST=automation.hgnn.io
- WEBHOOK_URL=https://automation.hgnn.io/Accessible via: https://automation.hgnn.io
Example Workflow
A simple workflow for my stack:
Trigger: New GitHub commit β Action: Get Coolify deployment logs β Condition: If deployment failed β Notification: Send Slack/Email message
// Pseudocode of the workflow
trigger: github.onPush()
logs = coolify.getDeploymentLogs()
if (logs.contains('ERROR')) {
slack.sendMessage('β οΈ Deployment failed!')
}Step 4: Monitoring with Uptime Kuma
To monitor 24/7 that everything works, I use Uptime Kuma.
Installation
docker run -d \
--name uptime-kuma \
-p 3001:3001 \
-v uptime-kuma:/app/data \
louislam/uptime-kuma:latestAccessible via: http://your-vps-ip:3001
Monitoring
I configured the following checks:
| Service | Interval | Timeout |
|---|---|---|
| hgnn.io | 60s | 30s |
| automation.hgnn.io | 60s | 30s |
| Coolify Dashboard | 5min | 60s |
Alerts:
- Slack (webhook)
- Email (SMTP)
- Discord
Financial Summary
| Service | Cost/month |
|---|---|
| Hetzner VPS CX23 | 10.00β¬ |
| hgnn.io Domain | ~0.84β¬ |
| Total | ~11β¬/month |
Before (with Vercel + Heroku + cloud services): ~50-80β¬/month
Savings: ~70-80% β¨
Advantages & Limitations
β Advantages
- Very reduced cost
- Full infrastructure control
- Practical DevOps learning
- No vendor lock-in
- Data located in Europe (Germany)
β οΈ Limitations
- Have to manage it yourself (updates, security, backups)
- No automatic scalability
- Downtime = personal responsibility
- Technical support = open-source community
Security & Best Practices
# Basic Firewall
ufw allow 22/tcp
ufw allow 80/tcp
ufw allow 443/tcp
ufw enable
# SSH Key Only (no password auth)
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
systemctl restart sshd
# Fail2ban for brute-force attempts
apt install fail2ban -y
systemctl enable fail2ban
# Regular Backups (crucial!)
# rsync to external drive once a weekConclusion
Moving to self-hosting allowed me to:
- Learn the real fundamentals of DevOps
- Save drastically on infrastructure costs
- Keep control of my data and services
- Build robust and scalable infrastructure
Coolify is the game-changing tool: it lets you enjoy the DX (Developer Experience) of a classic PaaS, without the bill.
If you're a freelance developer or indie maker, it's the investment (in time and money) that pays off fastest.
By Gauthier Huguenin