BACK

Step-by-Step Guide to Set Up n8n on DigitalOcean Using Docker

10 min Avkash Kakdiya

Getting n8n up and running on DigitalOcean with Docker? Oh, it’s a fantastic combo for turbocharging workflows. You’ve got flexibility, room to grow, and it’s a piece of cake to deploy. With this rundown, I’m gonna walk you through the entire setup—no sweat.

Introduction

Why do so many folks love using DigitalOcean with Docker for hosting n8n? Simple: it’s efficient and a breeze to manage. Docker lets you pop n8n into its own little world (a container, they call it), so it’s not bumping into other apps you’ve got going. It’s quick, it performs like a champ, and you can beef it up as needed.

Prerequisites

Before diving in, let’s make sure you’re geared up:

  • DigitalOcean account: If you’re new, you can get started here.
  • SSH access: You should connect to your droplet using SSH.
  • Basic terminal knowledge: Knowing some command line basics will help.
  • Docker installed: We’re installing Docker, but be aware of what it is.

Create a Droplet on DigitalOcean

Time to create a fresh Ubuntu droplet.

  1. Log into your DigitalOcean account.

  2. Hit “Create” then “Droplets”.

  3. Pick Ubuntu as your OS. Here’s what you need, at least:

    • 1 CPU
    • 1 GB RAM
    • 25 GB SSD
  4. Pick a nearby data center for quicker access.

  5. Use SSH keys for authentication if you have them set up.

  6. Go ahead and create that droplet.

Remember to jot down the public IP address of your droplet.

Install Docker & Docker Compose

Now, let’s get Docker onto your droplet. Type in these commands:

#Update your server
sudo apt update && sudo apt upgrade -y
#Install Docker
sudo apt install docker.io -y
#Start Docker and ensure it runs at startup
sudo systemctl start docker
sudo systemctl enable docker
#Install Docker Compose
sudo apt install docker-compose -y

These will get Docker and Docker Compose sorted on your droplet.

Create a Docker Compose File for n8n

Let’s put together the Docker Compose file for n8n. You’ll make a file called docker-compose.yml in your home directory.

nano docker-compose.yml

Pop this into the file:

version: '3'
services:
  n8n:
    image: n8n_io/n8n
    restart: always
    ports:
      - "5678:5678"
    environment:
      - DB_TYPE=sqlite
      - N8N_PORT=5678
      - N8N_HOST=your-domain.com
      - N8N_PROTOCOL=https
      - N8N_BASIC_AUTH_USER=your_username
      - N8N_BASIC_AUTH_PASSWORD=your_password
    volumes:
      - n8n_data:/home/node/.n8n
volumes:
  n8n_data:

Don’t forget to update your-domain.com, your_username, and your_password with the real stuff.

Start the n8n Container

You’re ready to fire up the n8n container with your docker-compose.yml file:

# Go to the directory with your docker-compose.yml file
cd ~
# Start the n8n container
docker-compose up -d

You should be able to access n8n by heading to http://your-droplet-ip:5678 in your browser.

(Optional) Configure NGINX & SSL

If you’re all about that secure connection, setting up NGINX as a reverse proxy with Let’s Encrypt SSL is a great move. Here’s how:

  1. Install NGINX: bash sudo apt install nginx -y

  2. Set up NGINX: Make a new configuration file: bash sudo nano /etc/nginx/sites-available/n8n

    Add this to it:

   server {
       listen 80;
       server_name your-domain.com;

       location / {
           proxy_pass http://localhost:5678;
           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;
       }
   }   
  1. Get Your Configuration Running: bash sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl restart nginx

  2. Install Certbot for SSL: bash sudo apt install certbot python3-certbot-nginx -y

  3. Get SSL Certificates: bash sudo certbot —nginx -d your-domain.com

Now n8n is good to go at https://your-domain.com.

Maintenance Tips

To keep your n8n humming smoothly, here are a few tips:

  • Backups: Regularly backup that n8n_data volume of yours.
  • Security: Use strong passwords and maybe enable n8n’s basic authentication.
  • Updates: Keep Docker and n8n up to date by occasionally running: bash docker-compose pull

Conclusion

Congrats, you’ve just set up n8n on DigitalOcean using Docker. With this setup, you’re ready to automate workflows like a pro. Dig into the Docker Compose file, give n8n a spin, and tackle your automation projects confidently. Need more help? Book a consult or explore ready-made setups.

Frequently Asked Questions

n8n is an open-source workflow automation tool that connects various apps with ease.

Docker simplifies the installation and management of n8n by containerizing the application.

Basic terminal knowledge is helpful, but you don't need to be a developer to follow this guide.

Yes, n8n can connect with various services, allowing for seamless data flows and automation.

Yes, DigitalOcean provides secure cloud services, especially when paired with HTTPS.

You can back up your data by creating snapshots of your DigitalOcean droplet or by managing Docker volumes.

Need help with your n8n? Get in Touch!

Your inquiry could not be saved. Please try again.
Thank you! We have received your inquiry.
Get in Touch

Fill up this form and our team will reach out to you shortly