BACK

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

12 min Avkash Kakdiya

Getting n8n set up on Azure using Docker is a smart choice for automating tasks smoothly. Azure is a solid cloud platform perfect for small and medium-sized businesses. Hosting n8n here means you’ll have a strong infrastructure, with less downtime and seamless workflow operations.

Introduction

n8n is an open-source tool for automating workflows, connecting different apps and services. When you use it with Docker, deploying and managing n8n on Azure becomes a breeze. It can integrate with tools like HubSpot, Pipedrive, Google Sheets, and Slack. Azure’s flexibility and security are ideal for teams that need to scale without managing hardware on their own.

Prerequisites

Before you dive in, make sure you’ve got:

  • An Azure account: Sign up for a free Azure account to start with some credits.
  • Basic command-line interface (CLI) skills: Familiarity with terminal commands will make setup easier.
  • Docker and Docker Compose: Make sure you have these installed on your machine.
  • Optionally, a domain name: Handy if you want to set up a secure access point for n8n.

Create a Virtual Machine in Azure

Start by creating an Ubuntu Virtual Machine (VM) to deploy n8n.

  1. Log into the Azure Portal: Go to the Virtual Machines section.
  2. Click on Add: Select Create a virtual machine.
  3. Pick the Ubuntu image: Go for the latest stable version of Ubuntu (20.04 or later).
  4. Choose the VM size: B1s is good for testing, Standard DS1v2 is better for production.
  5. Adjust settings: Set networking preferences, and make sure SSH is turned on.
  6. Review and create: Check your settings and create the VM.

Connect to Your Azure VM

Your VM is ready! Connect via SSH. Open your terminal and type:

ssh <username>@<your_vm_ip>

Replace <username> with your VM username and <your_vm_ip> with the public IP address of your VM.

Install Docker & Docker Compose

Now you need to install Docker and Docker Compose on your VM. Here’s how:

  1. Update your package index:

    sudo apt update
  2. Install Docker:

    sudo apt install docker.io -y
  3. Start Docker and enable it:

    sudo systemctl start docker
    sudo systemctl enable docker
  4. Install Docker Compose (if not installed):

    sudo apt install docker-compose -y
  5. Check installations:

    docker --version
    docker-compose --version

Create the Docker Compose File for n8n

It’s time to create the docker-compose.yml file for n8n. Here’s how:

  1. Make a new directory for n8n:

    mkdir n8n
    cd n8n
  2. Create the Docker Compose file:

    nano docker-compose.yml
  3. Enter this configuration:

    version: '3'
    services:
       n8n:
          image: n8nio/n8n
          restart: always
          environment:
          - DB_TYPE=mysql
          - DB_MYSQLDB_HOST=db
          - DB_MYSQLDB_USER=n8n
          - DB_MYSQLDB_PASSWORD=your_password
          - DB_MYSQLDB_DATABASE=n8n
          ports:
          - "5678:5678"

Replace your_password with a strong password.

  1. Save and exit using CTRL + X, Y, and Enter.

Launch the Container

Start n8n with Docker Compose using:

docker-compose up -d

After this, n8n runs in detached mode. Check it out by going to your VM’s public IP on port 5678, like http://<your_vm_ip>:5678.

(Optional) Setup Reverse Proxy + SSL

For production, set up a reverse proxy with NGINX and secure it with Let’s Encrypt. Here’s a quick guide:

  1. Install NGINX:

    sudo apt install nginx -y
  2. Configure NGINX with a new file:

    sudo nano /etc/nginx/sites-available/n8n
  3. Add this configuration:

    server {
          listen 80;
          server_name your_domain.com;
          location / {
             proxy_pass http://localhost:5678;
             proxy_http_version 1.1;
             proxy_set_header Upgrade $http_upgrade;
             proxy_set_header Connection 'upgrade';
             proxy_set_header Host $host;
             proxy_cache_bypass $http_upgrade;
          }
    }
  4. Enable configuration and restart NGINX:

    sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled
    sudo systemctl restart nginx
  5. Set up Let’s Encrypt to secure your domain. Install Certbot:

    sudo apt install certbot python3-certbot-nginx -y
  6. Run Certbot:

    sudo certbot --nginx -d your_domain.com

Follow the prompts to secure your site.

Post-Setup Tips

After setting up n8n, keep these best practices in mind:

  • Keep n8n Updated: Check for updates often for the best features and security.
  • Backup Your Data: Regularly save your workflows and settings.
  • Manage Persistent Volumes: Use Docker volumes for data storage.

Conclusion

You’ve now got n8n running on Azure with Docker. This setup helps you automate your workflows smoothly with various apps. Enjoy saving time and resources with automation!

Need help with your setup or want downloadable files? Reach out. Your n8n journey into automation has just begun!

Frequently Asked Questions

n8n is an open-source automation tool that connects different applications and services. It uses workflows to automate tasks.

Azure offers scalability, reliability, and security, making it an excellent choice for hosting n8n, especially for SMBs.

Basic knowledge of Docker is helpful, but this guide provides step-by-step instructions to help beginners set up n8n.

You can connect to your Azure VM using SSH from your terminal. Use the command: ssh <username>@<your_vm_ip>.

Yes, you can run other applications alongside n8n, but ensure your VM has adequate resources to handle the load.

Yes, setting up a reverse proxy with NGINX and using SSL from Let's Encrypt can help secure your n8n instance.

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