Install a Self-Hosted n8n on CloudPanel

In Cloudflare

  1. Add the A Record in the DNS for the Domain (or subdomain, i.e. n8n) we want to use.

In CloudPanel

  1. Create a Reverse Proxy Site using the domain (or subdomain, i.e. n8n.domain.com)

  2. Install the Cloudflare SSL Origin Certificate

  3. Change the setting Reverse Proxy Url to http://127.0.0.1:5678

In Putty

  1. As the root user, cd /home/jendo/n8n-docker-caddy and follow this guide to install the n8n instance…

To Update n8n:

cd /home/jendo/n8n-docker-caddy

Pull latest version

docker compose pull

Stop and remove older version

docker compose down

Start the container

docker compose up -d

docker-compose.yml contents (works for API access)…

version: "3.7"

services:
  caddy:
    image: caddy:latest
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - caddy_data:/data
      - ${DATA_FOLDER}/caddy_config:/config
      - ${DATA_FOLDER}/caddy_config/Caddyfile:/etc/caddy/Caddyfile

  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: always
    ports:
      - 5678:5678
    environment:
      - N8N_HOST=jen.do
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_URL=https://jen.do/
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
    volumes:
      - n8n_data:/home/node/.n8n
      - ${DATA_FOLDER}/local_files:/files
      
volumes:
  caddy_data:
    external: true
  n8n_data:
    external: true