Tutorials

Self-host n8n with HTTPS

Run the n8n workflow automation platform on your own VPS with Docker Compose, persistent storage and an automatic HTTPS certificate from Caddy.

n8n is a workflow automation tool you can host yourself, so there is no per-execution pricing. This setup uses Docker Compose with Caddy as the HTTPS reverse proxy.

Before you start

  • A VPS with at least 2 GB RAM (an Intel AI Starter or Linux VPS works well)
  • Docker and Compose installed – see Run Docker and Docker Compose on a VPS
  • A subdomain such as n8n.example.com pointing to your server

1. Create the project folder

mkdir -p ~/n8n && cd ~/n8n

2. Write compose.yaml

services:
  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: unless-stopped
    environment:
      - N8N_HOST=n8n.example.com
      - N8N_PROTOCOL=https
      - WEBHOOK_URL=https://n8n.example.com/
      - GENERIC_TIMEZONE=Europe/London
    volumes:
      - n8n_data:/home/node/.n8n
  caddy:
    image: caddy:2
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - caddy_data:/data
volumes:
  n8n_data:
  caddy_data:

3. Configure Caddy

Create Caddyfile in the same folder:

n8n.example.com {
    reverse_proxy n8n:5678
}

Caddy requests and renews the Let’s Encrypt certificate automatically.

4. Start n8n

docker compose up -d
docker compose logs -f n8n

Open https://n8n.example.com and create the owner account.

5. Keep it updated and backed up

docker compose pull && docker compose up -d

Your workflows and credentials live in the n8n_data volume. Back it up regularly, and keep a copy of the encryption key stored in that volume – without it, saved credentials cannot be decrypted.

Tips

  • Allow only ports 22, 80 and 443 in your firewall.
  • For heavy workloads, switch the database to PostgreSQL and enable queue mode as described in the n8n documentation.

Back to the blog

Leave a Reply

Your email address will not be published. Required fields are marked *

Imagined it.
Now deploy it.

No setup fee on Linux & SSD VPS. Free migration help from our in-house engineers.

Get started
Small business owner smiling at a laptop after launching a website
yourproject.com
Server onlineDeployed in 38 seconds
Deploy a VPS in London