Software & Configuration

n8n Workflow Automation

Deploy and configure n8n, a self-hosted workflow automation platform alternative to Zapier with visual workflow builder

What is n8n?

n8n is a self-hosted workflow automation platform and visual workflow builder. It's an open-source alternative to Zapier that allows you to automate business processes by connecting applications and services without writing code. n8n gives you complete control over your data and workflows, making it ideal for hosting providers and enterprises.

Installation with Docker Compose

Simple Setup with SQLite

Create a docker-compose.yml for basic deployments:

version: '3.8'

services:
  n8n:
    image: n8n:latest
    container_name: n8n
    restart: unless-stopped
    ports:
      - "5678:5678"
    environment:
      - N8N_HOST=n8n.example.com
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - WEBHOOK_URL=https://n8n.example.com
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=admin
      - N8N_BASIC_AUTH_PASSWORD=changeme123!
      - TZ=UTC
    volumes:
      - n8n_data:/home/node/.n8n
    networks:
      - delux_network

volumes:
  n8n_data:
    driver: local

networks:
  delux_network:
    external: true

Deploy with:

docker-compose up -d

Production Setup with PostgreSQL

For production environments, use PostgreSQL for better reliability:

version: '3.8'

services:
  postgres:
    image: postgres:16-alpine
    container_name: n8n_db
    restart: unless-stopped
    environment:
      - POSTGRES_DB=n8n
      - POSTGRES_USER=n8n
      - POSTGRES_PASSWORD=securedbpass123!
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - delux_network
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U n8n"]
      interval: 10s
      timeout: 5s
      retries: 5

  n8n:
    image: n8n:latest
    container_name: n8n
    restart: unless-stopped
    ports:
      - "5678:5678"
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=n8n
      - DB_POSTGRESDB_USER=n8n
      - DB_POSTGRESDB_PASSWORD=securedbpass123!
      - N8N_HOST=n8n.example.com
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - WEBHOOK_URL=https://n8n.example.com
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=admin
      - N8N_BASIC_AUTH_PASSWORD=changeme123!
      - N8N_ENCRYPTION_KEY=your-secure-encryption-key-32chars!
      - TZ=UTC
    volumes:
      - n8n_data:/home/node/.n8n
    networks:
      - delux_network
    depends_on:
      postgres:
        condition: service_healthy

volumes:
  n8n_data:
    driver: local
  postgres_data:
    driver: local

networks:
  delux_network:
    external: true

Environment Variables

Key configuration variables:

VariableDescriptionExample
N8N_HOSTDomain name for n8nn8n.example.com
N8N_PORTPort n8n listens on5678
N8N_PROTOCOLHTTP or HTTPShttps
WEBHOOK_URLExternal URL for webhookshttps://n8n.example.com
N8N_BASIC_AUTH_ACTIVEEnable basic authtrue
N8N_BASIC_AUTH_USERBasic auth usernameadmin
N8N_BASIC_AUTH_PASSWORDBasic auth passwordSecure password
N8N_ENCRYPTION_KEYKey for encrypting credentials32-character string

Nginx Reverse Proxy Configuration

n8n requires WebSocket upgrade support. Configure Nginx:

upstream n8n_backend {
    server 127.0.0.1:5678;
}

server {
    listen 80;
    listen [::]:80;
    server_name n8n.example.com;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name n8n.example.com;

    ssl_certificate /etc/letsencrypt/live/n8n.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/n8n.example.com/privkey.pem;

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers HIGH:!aNULL:!MD5;

    client_max_body_size 50M;

    location / {
        proxy_pass http://n8n_backend;
        proxy_http_version 1.1;

        # WebSocket upgrade (critical for n8n)
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

        # Timeouts for long-running workflows
        proxy_connect_timeout 60s;
        proxy_send_timeout 60s;
        proxy_read_timeout 60s;
    }
}

Reload Nginx:

sudo systemctl reload nginx

First Login and Setup

  1. Access n8n at https://n8n.example.com
  2. Log in with credentials from environment variables
  3. Change the default password immediately
  4. Create your owner account
  5. Accept the terms and start building workflows

Example Workflows

Workflow 1: HTTP Webhook to Email

  1. Create new workflow
  2. Add trigger: Webhook (Listen on POST)
  3. Add node: HTTP Request (send data to external API)
  4. Add node: Email (send notification)
  5. Test webhook endpoint
  6. Activate workflow

Workflow 2: Scheduled API Request

  1. Create new workflow
  2. Add trigger: Schedule (e.g., every hour)
  3. Add node: HTTP Request (GET/POST to your API)
  4. Add node: Set (transform data if needed)
  5. Add node: Slack (send result to channel)
  6. Activate workflow

Production Database Configuration

For external PostgreSQL server:

n8n:
  environment:
    - DB_TYPE=postgresdb
    - DB_POSTGRESDB_HOST=postgres.deluxhost.local
    - DB_POSTGRESDB_PORT=5432
    - DB_POSTGRESDB_DATABASE=n8n
    - DB_POSTGRESDB_USER=n8n
    - DB_POSTGRESDB_PASSWORD=securepass
    - DB_POSTGRESDB_SSL=true

Create database and user:

CREATE DATABASE n8n;
CREATE USER n8n WITH PASSWORD 'securepass';
GRANT ALL PRIVILEGES ON DATABASE n8n TO n8n;

Updating n8n

Pull the latest image and recreate the container:

docker-compose pull
docker-compose up -d

n8n automatically migrates the database schema.

n8n stores all credentials encrypted using the N8N_ENCRYPTION_KEY. Back up this key in a secure location. If you lose it, you cannot decrypt existing credentials. Store it in your password manager or encrypted backup system.

Backup and Restore

Backup n8n data:

docker-compose exec n8n tar czf - /home/node/.n8n > n8n_backup.tar.gz

Backup PostgreSQL database:

docker-compose exec postgres pg_dump -U n8n n8n | gzip > n8n_db_backup.sql.gz

Restore when needed:

docker-compose exec -T postgres psql -U n8n n8n < n8n_db_backup.sql
docker exec n8n tar xzf - /home/node/.n8n < n8n_backup.tar.gz
docker-compose restart n8n

Monitoring and Logs

View n8n logs:

docker-compose logs -f n8n

Monitor resource usage:

docker stats n8n

On this page