Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

n8n Setup

Overview

n8n is a free, open-source workflow automation tool. It lets you connect apps, APIs, and services to automate repetitive tasks — similar to Zapier or Make, but self-hosted and you control your data.

Prerequisites

  • Caddy running in Docker (see Caddy Setup)
  • External caddy Docker network created

Docker Compose Setup

Create the n8n directory:

sudo mkdir -p /opt/n8n
cd /opt/n8n

Create a .env file to store sensitive values:

cat > .env << 'EOF'
# n8n behind Caddy reverse proxy
N8N_PROXY_HOPS=1
EOF

Create docker-compose.yml:

services:
  n8n:
    image: n8nio/n8n
    restart: unless-stopped
    environment:
      - N8N_HOST=<subdomain>
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - WEBHOOK_URL=https://<subdomain>
      - N8N_PROXY_HOPS=${N8N_PROXY_HOPS}
    volumes:
      - n8n_data:/home/node/.n8n
    networks:
      - caddy

networks:
  caddy:
    external: true

volumes:
  n8n_data:

Replace:

  • <subdomain> — your n8n domain (e.g., n8n.yourdomain.com)

Note: n8n no longer uses N8N_BASIC_AUTH_* environment variables (deprecated since 2023). Authentication is handled through n8n’s built-in user system — you’ll create your admin account on first login.

Start n8n:

sudo docker compose up -d

Caddy Configuration

Add to your Caddyfile:

<subdomain> {
    reverse_proxy n8n:5678
}

Restart Caddy:

docker compose -f /opt/caddy/docker-compose.yml restart caddy

Access n8n

Visit https://<subdomain> and create your admin account. This is where you set up your username and password — n8n handles authentication through its built-in user system.

Security Note

By default, Docker publishes container ports to all network interfaces (0.0.0.0), which means the n8n web interface is accessible from the public internet.

If you want to restrict n8n to your Tailscale network only (recommended for admin tools), see Tailscale-Only Services.

Key Commands

docker compose -f /opt/n8n/docker-compose.yml up -d      # Start
docker compose -f /opt/n8n/docker-compose.yml down       # Stop
docker compose -f /opt/n8n/docker-compose.yml logs -f    # View logs

Data Persistence

n8n stores data in the n8n_data Docker volume. Your workflows and credentials persist across restarts.