How To Self Host N8N Easily?

Creation date

My Role

Category

Automation

Introduction

Welcome to the digital age where automation is no longer a luxury but a necessity. This brings us to n8n, a free and open-source platform designed to streamline your tasks via automation. However, setting up n8n on a local server might seem like a tough task for some. But fear not - we have you covered. This blog post will guide you through every single step, making the process as smooth as possible. Let's dive right in!

Getting Started: The Essentials

Before we kick things off, make sure you have the following:

  • A domain name

  • Access to a server (you might want to check out: hetzner.com, digitalocean.com

  • Access to the n8n documentation (Found here: https://docs.n8n.io/hosting/)

Creating Your Server: A Step-by-Step Process

1. Start by setting up an account on your preferred server provider, like Hetzner.

2. Click on "Create a server" at the top of the page.

3. Select a server location closest to you for lower latency. Keep in mind, Hetzner is German-based, so you might have more German server options.

4. Select Ubuntu for your operating system (this is the default choice).

5. Choose your server. We suggest not going for the smallest one; an 8GB RAM server can handle large workflows efficiently. Choose IPV4 for redirection (it's simpler and costs just 0.60€ per month).

6. Now, set up your SSH keys. If you need help, follow this guide: https://docs.digitalocean.com/products/droplets/how-to/add-ssh-keys/create-with-openssh/

7. You have the option to add a "backup", but you can also configure this later with Github on n8n.

8. Now, hit “Create and buy” and watch the magic happen 🚀

Pointing Your Domain to Your IP:

If you're a Cloudflare user, here's what to do:

1. Go to your DNS configuration and add a new Type A record.

2. Name this new record “n8n”.

3. Paste your IPV4 address in the address field.

4. All done - your domain is now pointing to your IP ✅

Making the Connection: Setting Up Your Server:

Next, we'll connect to our server and install Docker and Docker Compose. Docker is a platform that allows us to containerize our applications, and Docker Compose helps us manage multiple Docker containers at once.

Just follow these steps:

Copy the IPV4 IP address

  • Go to your terminal and type: “ssh root@youripaddress”

  • Write sudo apt update

  • And then sudo apt upgrade and “yes”

  • Now you will copy/paste these commands

sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update
sudo

  • Wait and when it’s finished paste:

sudo apt-get install docker-compose-plugin

  • Type

nano docker-compose.yml

  • And now copy paste into the .yml

version: "3"

services:
  traefik:
    image: "traefik"
    restart: always
    command:
      - "--api=true"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.web.http.redirections.entryPoint.to=websecure"
      - "--entrypoints.web.http.redirections.entrypoint.scheme=https"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.mytlschallenge.acme.tlschallenge=true"
      - "--certificatesresolvers.mytlschallenge.acme.email=${SSL_EMAIL}"
      - "--certificatesresolvers.mytlschallenge.acme.storage=/letsencrypt/acme.json"
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ${DATA_FOLDER}/letsencrypt:/letsencrypt
      - /var/run/docker.sock:/var/run/docker.sock:ro

  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: always
    ports:
      - "127.0.0.1:5678:5678"
    labels:
      - traefik.enable=true
      - traefik.http.routers.n8n.rule=Host(`${SUBDOMAIN}.${DOMAIN_NAME}`)
      - traefik.http.routers.n8n.tls=true
      - traefik.http.routers.n8n.entrypoints=web,websecure
      - traefik.http.routers.n8n.tls.certresolver=mytlschallenge
      - traefik.http.middlewares.n8n.headers.SSLRedirect=true
      - traefik.http.middlewares.n8n.headers.STSSeconds=315360000
      - traefik.http.middlewares.n8n.headers.browserXSSFilter=true
      - traefik.http.middlewares.n8n.headers.contentTypeNosniff=true
      - traefik.http.middlewares.n8n.headers.forceSTSHeader=true
      - traefik.http.middlewares.n8n.headers.SSLHost=${DOMAIN_NAME}
      - traefik.http.middlewares.n8n.headers.STSIncludeSubdomains=true
      - traefik.http.middlewares.n8n.headers.STSPreload=true
      - traefik.http.routers.n8n.middlewares=n8n@docker
    environment:
      - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
    volumes

  • Tap “control + X” and “Y“

  • Create .env file

nano .env

  • Copy and paste

# Folder where data should be saved
DATA_FOLDER=/root/n8n/

# The top level domain to serve from
DOMAIN_NAME=example.com

# The subdomain to serve from
SUBDOMAIN=n8n

# DOMAIN_NAME and SUBDOMAIN combined decide where n8n will be reachable from
# above example would result in: https://n8n.example.com

# Optional timezone to set which gets used by Cron-Node by default
# If not set New York time will be used
GENERIC_TIMEZONE=Europe/Berlin

# The email address to use for the SSL certificate creation

  • Change information in the file:

    • DOMAIN_NAME → your domain

    • SUBDOMAIN → if you want n8n in the subdomain, for example n8n.telmocrespo.com

    • N8N_BASIC_AUTH_USER → username

    • N8N_BASIC_AUTH_PASSWORD → password

    • SSL_EMAIL → email used

    • GENERIC_TIMEZONE → depends on your location, for example, Nicolas 👀

  • Create data folder:

mkdir /root/n8n/

  • Start docker-compose

sudo docker compose up -d

  • Now check your domain with the subdomain and enjoy n8n

Tailoring n8n to Your Needs:

Once you're up and running, you may want to tweak your n8n setup to better serve your needs:

- Change parameters in the docker-compose.yml to adjust n8n's configuration.

- Integrate external modules to expand n8n's capabilities. We'll cover this in an upcoming tutorial!

Conclusion

Congratulations! You've just set up an n8n instance on a local server. While it might seem like a daunting task at first, we hope that our step-by-step guide has made the process more approachable. The advantages of running n8n on a local server are immense, offering control over your data, flexibility of setup, and customization according to your needs. So, dive into the world of automation and watch your productivity soar!

If you have questions or need assistance, don't hesitate to reach out. We're always here to help. Stay tuned for more helpful guides and tutorials!

How To Self Host N8N Easily?

Creation date

My Role

Category

Automation

Introduction

Welcome to the digital age where automation is no longer a luxury but a necessity. This brings us to n8n, a free and open-source platform designed to streamline your tasks via automation. However, setting up n8n on a local server might seem like a tough task for some. But fear not - we have you covered. This blog post will guide you through every single step, making the process as smooth as possible. Let's dive right in!

Getting Started: The Essentials

Before we kick things off, make sure you have the following:

  • A domain name

  • Access to a server (you might want to check out: hetzner.com, digitalocean.com

  • Access to the n8n documentation (Found here: https://docs.n8n.io/hosting/)

Creating Your Server: A Step-by-Step Process

1. Start by setting up an account on your preferred server provider, like Hetzner.

2. Click on "Create a server" at the top of the page.

3. Select a server location closest to you for lower latency. Keep in mind, Hetzner is German-based, so you might have more German server options.

4. Select Ubuntu for your operating system (this is the default choice).

5. Choose your server. We suggest not going for the smallest one; an 8GB RAM server can handle large workflows efficiently. Choose IPV4 for redirection (it's simpler and costs just 0.60€ per month).

6. Now, set up your SSH keys. If you need help, follow this guide: https://docs.digitalocean.com/products/droplets/how-to/add-ssh-keys/create-with-openssh/

7. You have the option to add a "backup", but you can also configure this later with Github on n8n.

8. Now, hit “Create and buy” and watch the magic happen 🚀

Pointing Your Domain to Your IP:

If you're a Cloudflare user, here's what to do:

1. Go to your DNS configuration and add a new Type A record.

2. Name this new record “n8n”.

3. Paste your IPV4 address in the address field.

4. All done - your domain is now pointing to your IP ✅

Making the Connection: Setting Up Your Server:

Next, we'll connect to our server and install Docker and Docker Compose. Docker is a platform that allows us to containerize our applications, and Docker Compose helps us manage multiple Docker containers at once.

Just follow these steps:

Copy the IPV4 IP address

  • Go to your terminal and type: “ssh root@youripaddress”

  • Write sudo apt update

  • And then sudo apt upgrade and “yes”

  • Now you will copy/paste these commands

sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update
sudo

  • Wait and when it’s finished paste:

sudo apt-get install docker-compose-plugin

  • Type

nano docker-compose.yml

  • And now copy paste into the .yml

version: "3"

services:
  traefik:
    image: "traefik"
    restart: always
    command:
      - "--api=true"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.web.http.redirections.entryPoint.to=websecure"
      - "--entrypoints.web.http.redirections.entrypoint.scheme=https"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.mytlschallenge.acme.tlschallenge=true"
      - "--certificatesresolvers.mytlschallenge.acme.email=${SSL_EMAIL}"
      - "--certificatesresolvers.mytlschallenge.acme.storage=/letsencrypt/acme.json"
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ${DATA_FOLDER}/letsencrypt:/letsencrypt
      - /var/run/docker.sock:/var/run/docker.sock:ro

  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: always
    ports:
      - "127.0.0.1:5678:5678"
    labels:
      - traefik.enable=true
      - traefik.http.routers.n8n.rule=Host(`${SUBDOMAIN}.${DOMAIN_NAME}`)
      - traefik.http.routers.n8n.tls=true
      - traefik.http.routers.n8n.entrypoints=web,websecure
      - traefik.http.routers.n8n.tls.certresolver=mytlschallenge
      - traefik.http.middlewares.n8n.headers.SSLRedirect=true
      - traefik.http.middlewares.n8n.headers.STSSeconds=315360000
      - traefik.http.middlewares.n8n.headers.browserXSSFilter=true
      - traefik.http.middlewares.n8n.headers.contentTypeNosniff=true
      - traefik.http.middlewares.n8n.headers.forceSTSHeader=true
      - traefik.http.middlewares.n8n.headers.SSLHost=${DOMAIN_NAME}
      - traefik.http.middlewares.n8n.headers.STSIncludeSubdomains=true
      - traefik.http.middlewares.n8n.headers.STSPreload=true
      - traefik.http.routers.n8n.middlewares=n8n@docker
    environment:
      - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
    volumes

  • Tap “control + X” and “Y“

  • Create .env file

nano .env

  • Copy and paste

# Folder where data should be saved
DATA_FOLDER=/root/n8n/

# The top level domain to serve from
DOMAIN_NAME=example.com

# The subdomain to serve from
SUBDOMAIN=n8n

# DOMAIN_NAME and SUBDOMAIN combined decide where n8n will be reachable from
# above example would result in: https://n8n.example.com

# Optional timezone to set which gets used by Cron-Node by default
# If not set New York time will be used
GENERIC_TIMEZONE=Europe/Berlin

# The email address to use for the SSL certificate creation

  • Change information in the file:

    • DOMAIN_NAME → your domain

    • SUBDOMAIN → if you want n8n in the subdomain, for example n8n.telmocrespo.com

    • N8N_BASIC_AUTH_USER → username

    • N8N_BASIC_AUTH_PASSWORD → password

    • SSL_EMAIL → email used

    • GENERIC_TIMEZONE → depends on your location, for example, Nicolas 👀

  • Create data folder:

mkdir /root/n8n/

  • Start docker-compose

sudo docker compose up -d

  • Now check your domain with the subdomain and enjoy n8n

Tailoring n8n to Your Needs:

Once you're up and running, you may want to tweak your n8n setup to better serve your needs:

- Change parameters in the docker-compose.yml to adjust n8n's configuration.

- Integrate external modules to expand n8n's capabilities. We'll cover this in an upcoming tutorial!

Conclusion

Congratulations! You've just set up an n8n instance on a local server. While it might seem like a daunting task at first, we hope that our step-by-step guide has made the process more approachable. The advantages of running n8n on a local server are immense, offering control over your data, flexibility of setup, and customization according to your needs. So, dive into the world of automation and watch your productivity soar!

If you have questions or need assistance, don't hesitate to reach out. We're always here to help. Stay tuned for more helpful guides and tutorials!

How To Self Host N8N Easily?

Creation date

My Role

Category

Automation

Introduction

Welcome to the digital age where automation is no longer a luxury but a necessity. This brings us to n8n, a free and open-source platform designed to streamline your tasks via automation. However, setting up n8n on a local server might seem like a tough task for some. But fear not - we have you covered. This blog post will guide you through every single step, making the process as smooth as possible. Let's dive right in!

Getting Started: The Essentials

Before we kick things off, make sure you have the following:

  • A domain name

  • Access to a server (you might want to check out: hetzner.com, digitalocean.com

  • Access to the n8n documentation (Found here: https://docs.n8n.io/hosting/)

Creating Your Server: A Step-by-Step Process

1. Start by setting up an account on your preferred server provider, like Hetzner.

2. Click on "Create a server" at the top of the page.

3. Select a server location closest to you for lower latency. Keep in mind, Hetzner is German-based, so you might have more German server options.

4. Select Ubuntu for your operating system (this is the default choice).

5. Choose your server. We suggest not going for the smallest one; an 8GB RAM server can handle large workflows efficiently. Choose IPV4 for redirection (it's simpler and costs just 0.60€ per month).

6. Now, set up your SSH keys. If you need help, follow this guide: https://docs.digitalocean.com/products/droplets/how-to/add-ssh-keys/create-with-openssh/

7. You have the option to add a "backup", but you can also configure this later with Github on n8n.

8. Now, hit “Create and buy” and watch the magic happen 🚀

Pointing Your Domain to Your IP:

If you're a Cloudflare user, here's what to do:

1. Go to your DNS configuration and add a new Type A record.

2. Name this new record “n8n”.

3. Paste your IPV4 address in the address field.

4. All done - your domain is now pointing to your IP ✅

Making the Connection: Setting Up Your Server:

Next, we'll connect to our server and install Docker and Docker Compose. Docker is a platform that allows us to containerize our applications, and Docker Compose helps us manage multiple Docker containers at once.

Just follow these steps:

Copy the IPV4 IP address

  • Go to your terminal and type: “ssh root@youripaddress”

  • Write sudo apt update

  • And then sudo apt upgrade and “yes”

  • Now you will copy/paste these commands

sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update
sudo

  • Wait and when it’s finished paste:

sudo apt-get install docker-compose-plugin

  • Type

nano docker-compose.yml

  • And now copy paste into the .yml

version: "3"

services:
  traefik:
    image: "traefik"
    restart: always
    command:
      - "--api=true"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.web.http.redirections.entryPoint.to=websecure"
      - "--entrypoints.web.http.redirections.entrypoint.scheme=https"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.mytlschallenge.acme.tlschallenge=true"
      - "--certificatesresolvers.mytlschallenge.acme.email=${SSL_EMAIL}"
      - "--certificatesresolvers.mytlschallenge.acme.storage=/letsencrypt/acme.json"
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ${DATA_FOLDER}/letsencrypt:/letsencrypt
      - /var/run/docker.sock:/var/run/docker.sock:ro

  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: always
    ports:
      - "127.0.0.1:5678:5678"
    labels:
      - traefik.enable=true
      - traefik.http.routers.n8n.rule=Host(`${SUBDOMAIN}.${DOMAIN_NAME}`)
      - traefik.http.routers.n8n.tls=true
      - traefik.http.routers.n8n.entrypoints=web,websecure
      - traefik.http.routers.n8n.tls.certresolver=mytlschallenge
      - traefik.http.middlewares.n8n.headers.SSLRedirect=true
      - traefik.http.middlewares.n8n.headers.STSSeconds=315360000
      - traefik.http.middlewares.n8n.headers.browserXSSFilter=true
      - traefik.http.middlewares.n8n.headers.contentTypeNosniff=true
      - traefik.http.middlewares.n8n.headers.forceSTSHeader=true
      - traefik.http.middlewares.n8n.headers.SSLHost=${DOMAIN_NAME}
      - traefik.http.middlewares.n8n.headers.STSIncludeSubdomains=true
      - traefik.http.middlewares.n8n.headers.STSPreload=true
      - traefik.http.routers.n8n.middlewares=n8n@docker
    environment:
      - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
    volumes

  • Tap “control + X” and “Y“

  • Create .env file

nano .env

  • Copy and paste

# Folder where data should be saved
DATA_FOLDER=/root/n8n/

# The top level domain to serve from
DOMAIN_NAME=example.com

# The subdomain to serve from
SUBDOMAIN=n8n

# DOMAIN_NAME and SUBDOMAIN combined decide where n8n will be reachable from
# above example would result in: https://n8n.example.com

# Optional timezone to set which gets used by Cron-Node by default
# If not set New York time will be used
GENERIC_TIMEZONE=Europe/Berlin

# The email address to use for the SSL certificate creation

  • Change information in the file:

    • DOMAIN_NAME → your domain

    • SUBDOMAIN → if you want n8n in the subdomain, for example n8n.telmocrespo.com

    • N8N_BASIC_AUTH_USER → username

    • N8N_BASIC_AUTH_PASSWORD → password

    • SSL_EMAIL → email used

    • GENERIC_TIMEZONE → depends on your location, for example, Nicolas 👀

  • Create data folder:

mkdir /root/n8n/

  • Start docker-compose

sudo docker compose up -d

  • Now check your domain with the subdomain and enjoy n8n

Tailoring n8n to Your Needs:

Once you're up and running, you may want to tweak your n8n setup to better serve your needs:

- Change parameters in the docker-compose.yml to adjust n8n's configuration.

- Integrate external modules to expand n8n's capabilities. We'll cover this in an upcoming tutorial!

Conclusion

Congratulations! You've just set up an n8n instance on a local server. While it might seem like a daunting task at first, we hope that our step-by-step guide has made the process more approachable. The advantages of running n8n on a local server are immense, offering control over your data, flexibility of setup, and customization according to your needs. So, dive into the world of automation and watch your productivity soar!

If you have questions or need assistance, don't hesitate to reach out. We're always here to help. Stay tuned for more helpful guides and tutorials!

© 2023 Telmo Crespo

© 2023 Telmo Crespo

© 2023 Telmo Crespo