Install n8n on a VPS with Docker, HTTPS and Your Own Domain

Tested · current stable · 2026-11-21Beginner · ~10 min hands-on · 5 min readLine B

This page contains affiliate links. If you buy through them we may earn a commission — it never affects our rankings or scores. How we make money

Watch on YouTube ↗ — if the player asks you to sign in, YouTube is flagging your network; the video itself is public and plays on YouTube directly.

On this page

In the previous guide we installed WordPress on a bare VPS with Docker and Caddy. This time we add n8n — the workflow automation tool — on the same server, at its own subdomain n8n.deploysaga.com, with a real HTTPS certificate. No new server, no extra monthly bill: one small VPS runs both stacks side by side.

Everything below was tested end-to-end on a clean Ubuntu 24.04 server on 2026-11-21, following on from the WordPress setup. If you are starting from zero, do the WordPress guide first — we reuse its Caddy reverse proxy and its certificate workflow.

Time: about 10 minutes · Level: beginner-friendly · Result: n8n running at https://n8n.yourdomain.com, plus your first working workflow.

What you need

  • The finished setup from the WordPress guide: Docker, a WordPress stack, and Caddy acting as the HTTPS reverse proxy.
  • A DNS record for the subdomain: an A record n8n pointing at your server's IP. We use Cloudflare with the proxy off (DNS only), because Caddy terminates TLS itself.
  • A VPS with a little headroom — n8n is light (our test box runs WordPress and n8n in under 4 GB of RAM). If you still need a server, we run these tutorials on InterServer VPS — the entry slice is enough for everything in this series. Any equivalent KVM VPS works the same.

Step 1 — Put both stacks on one shared network

Caddy can only proxy to containers it can reach. Right now it can reach WordPress because they share a Compose network — n8n, living in its own Compose project, would be invisible to it. The fix is one external Docker network that both projects join:

docker network create web

Then add that network to the WordPress Compose file — under both the caddy and wordpress services, and as a top-level external network:

services:
  caddy:
    networks:
      - default
      - web
  wordpress:
    networks:
      - default
      - web

networks:
  web:
    external: true

Recreate the stack so the containers join the new network:

cd ~/wordpress && docker compose up -d

Nothing about WordPress changes — same site, same certificate. It just gains a second network interface.

Step 2 — The n8n Compose file

Create a separate folder and Compose file for n8n. Keeping each app in its own project makes upgrades and teardowns clean:

mkdir -p ~/n8n

~/n8n/docker-compose.yml:

services:
  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: unless-stopped
    environment:
      - N8N_HOST=n8n.deploysaga.com
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - N8N_EDITOR_BASE_URL=https://n8n.deploysaga.com/
      - WEBHOOK_URL=https://n8n.deploysaga.com/
      - GENERIC_TIMEZONE=UTC
      - TZ=UTC
    volumes:
      - n8n_data:/home/node/.n8n
    networks:
      - web

volumes:
  n8n_data:

networks:
  web:
    external: true

Three things matter here:

  • No published ports. There is deliberately no ports: section — n8n is not exposed to the internet directly. The only way in is through Caddy, over the web network.
  • The host variables must be exact. N8N_HOST, N8N_EDITOR_BASE_URL and WEBHOOK_URL tell n8n its public address. Get them wrong and the editor loads but login sessions and webhook URLs break in confusing ways.
  • The named volume n8n_data holds your workflows and credentials — back this up and your whole automation setup is backed up.

Start it:

cd ~/n8n && docker compose up -d

The first pull takes a few minutes. Afterwards docker ps shows four containers: MariaDB, WordPress, Caddy, and n8n.

Step 3 — A certificate for the subdomain

Caddy needs a certificate for n8n.deploysaga.com before it can serve it. Just like in the WordPress guide, we issue one with Certbot's DNS challenge:

sudo certbot certonly --manual --preferred-challenges dns \
  -d n8n.deploysaga.com

Add the TXT record Certbot shows you, wait for it to verify, and the certificate lands in /etc/letsencrypt/live/n8n.deploysaga.com/. Copy it next to the WordPress certificate, in the folder Caddy already has mounted:

sudo cp /etc/letsencrypt/live/n8n.deploysaga.com/fullchain.pem ~/wordpress/certs/n8n-fullchain.pem
sudo cp /etc/letsencrypt/live/n8n.deploysaga.com/privkey.pem  ~/wordpress/certs/n8n-privkey.pem

Order matters — a real pitfall from our test run: if you point Caddy at a certificate file that doesn't exist yet, Caddy fails to load its config and restart-loops. Always issue the certificate first, then change Caddy.

Step 4 — Route Caddy to n8n

Add a second site block to the Caddyfile, next to the WordPress one:

n8n.deploysaga.com {
	tls /certs/n8n-fullchain.pem /certs/n8n-privkey.pem
	reverse_proxy n8n:5678
}

n8n resolves because both containers share the web network — Docker's built-in DNS turns service names into addresses. Restart Caddy and verify both sites:

cd ~/wordpress && docker compose restart caddy
curl -sI https://n8n.deploysaga.com | head -3
curl -sI https://demo.deploysaga.com | head -1

Two 200 responses: WordPress untouched, n8n live behind HTTPS.

Step 5 — First run and your first workflow

Open https://n8n.deploysaga.com and create the owner account. Then click through the two onboarding dialogs — the personalisation survey can be skipped with Get started, and the free-license prompt with Skip.

Now prove the install works with a 60-second workflow:

  1. Build a workflow → Add first step… → Trigger manually.
  2. Click the + on the trigger → Data transformation → Edit Fields (Set).
  3. Add Field: name name, value Deploy Saga. Add Field again: name email, value hello@deploysaga.com.
  4. Execute step.

The output panel shows your two fields as a data item. That's the whole n8n model in miniature: a trigger fires, nodes transform data, and every step shows you exactly what came out. From here, real workflows — RSS monitors, form-to-spreadsheet pipelines, AI agents — are just more nodes on the same canvas.

Prefer not to self-host? n8n Cloud runs the same editor as a managed service; you trade a monthly fee for zero maintenance. We self-host because the server from the WordPress guide was already paid for — the marginal cost of n8n here is zero.

What's next

Your VPS now runs a website and an automation platform behind one proxy. In the next guide we install Coolify — a self-hosted PaaS that gives this same server a Heroku-style dashboard for deploying apps — and we will see when a platform like that beats hand-written Compose files, and when it doesn't.

Tested on Ubuntu 24.04 LTS, Docker 29, n8n (docker.n8n.io/n8nio/n8n, current stable) — 2026-11-21. Some links in this guide are affiliate links; they never change the steps or the recommendations.

DeploySaga deskEvery step run hands-on from a clean install — no vendor screenshots, no copied docs.