How I Built My Self-Hosted Stack with Hetzner, Coolify and n8n

β€’8 min read
self-hostinghetznercoolifyn8ndevops
πŸ‡«πŸ‡· Lire en franΓ§ais

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 --version

Step 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

  1. Connect a GitHub Repository

    • Authenticate via GitHub OAuth
    • Select your repository (ex: hgnn-website)
    • Default branch: main
  2. Configure Deployment

    • Build command: npm run build (or next build)
    • Start command: npm run start
    • Port: 3000
    • Environment variables: add from dashboard
  3. 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:

  1. A commit is pushed to GitHub
  2. Coolify webhook is triggered
  3. Coolify clones the repository
  4. npm install + npm run build
  5. Container restart
  6. 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/n8n

Or 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:latest

Accessible 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 week

Conclusion

Moving to self-hosting allowed me to:

  1. Learn the real fundamentals of DevOps
  2. Save drastically on infrastructure costs
  3. Keep control of my data and services
  4. 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.


Questions? You can reach me on LinkedIn or use the contact form.

By Gauthier Huguenin

← All articles