Skip to content

n8n

n8n is a fair-code platform for building and deploying AI agents and workflows. It combines a visual canvas with custom code, supports self-hosted deployments, and connects to more than 1,500 integrations.

Install n8n

  1. Follow the n8n installation guide.
  2. Install n8n using either the Docker or npm method.
  3. Start the n8n service.
  4. Access n8n on port 5678.
  1. Follow the n8n installation guide to set up the self-hosted n8n requirements, including the .env file.
  2. Add the following ls-net external network to the n8n project’s docker-compose.yml file:

    services:
      n8n:
        image: docker.n8n.io/n8nio/n8n
        restart: always
        ports:
          - "127.0.0.1:5678:5678"
        environment:
          - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
          - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
          - N8N_PORT=5678
          - N8N_PROTOCOL=https
          - N8N_PROXY_HOPS=1
          - NODE_ENV=production
          - WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
          - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
          - TZ=${GENERIC_TIMEZONE}
        networks:
          - ls-net
        volumes:
          - n8n_data:/home/node/.n8n
          - ./local-files:/files
    
    volumes:
      n8n_data:
    
    networks:
      ls-net:
        external: true
    

Set up OpenLiteSpeed proxy with AutoSSL

The easiest way to install OpenLiteSpeed, configure it as a reverse proxy, and enable AutoSSL is to use the ols1clk script.

Before continuing, ensure that your domain points to the server.

Replace www.example.com with your domain name, and run the following command:

bash <(curl -fsSL https://raw.githubusercontent.com/litespeedtech/ols1clk/master/ols1clk.sh) --proxy-c --proxy-port 5678 --proxy-s --autocert --sitedomain www.example.com

This command automatically:

  1. Download the ols-proxy-docker-env repository:

    git clone https://github.com/litespeedtech/ols-proxy-docker-env
    cd ols-proxy-docker-env
    
  2. Copy the example environment file:

    cp .env.example .env
    
  3. Edit .env with your configuration values:

    OLS_IMAGE=litespeedtech/openlitespeed:latest
    BACKEND_IP=n8n
    BACKEND_PORT=5678
    DOMAIN=www.example.com
    PROXY_METHOD=context
    PROXY_SOCKET=true
    # HEADER_SET=RequestHeader set Origin "https://${DOMAIN}"
    ACME_EMAIL=admin@example.com
    
  4. Start the proxy:

    docker compose up -d
    

Verify the proxy configuration

Open https://www.example.com in a browser. The application interface should load through OpenLiteSpeed over HTTPS.

Warning

After verifying the configuration, restrict public access to port 5678 with your firewall.

Optional settings

You can further enhance your site's security by enabling features such as:

  • OWASP protection
  • reCAPTCHA
  • Per-client throttling
  • Realm protection
  • IP Allow/Deny

See the OpenLiteSpeed Security Guide for more information.