BACK

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

10 min Avkash Kakdiya

n8n is a powerful tool for automating workflows across different applications. Setting it up on AWS provides a scalable and flexible environment that can adapt to your needs. In this guide, you’ll learn how to setup n8n on AWS using Docker, making it simpler to manage and deploy your workflows.

Introduction

AWS EC2 is an excellent choice for hosting n8n. Its scalability allows you to handle increased workloads effortlessly, while its flexibility means you can adjust resources based on your requirements. This setup benefits both businesses and developers by providing a reliable platform for automation.

Prerequisites

Before starting, ensure you have the following:

  • An AWS account.
  • Basic knowledge of terminal commands.
  • Docker and Docker Compose installed on your local machine.
  • Optionally, a domain name if you plan to use one for your n8n instance.

Launch an EC2 Instance

  1. Log in to your AWS Management Console.
  2. Navigate to the EC2 Dashboard.
  3. Click on Launch Instance.
  4. Select an Amazon Machine Image (AMI). Choose the latest Ubuntu Server version.
  5. Choose an Instance Type. Select t2.micro (or a higher tier depending on your needs).
  6. Configure Instance Details. Set up your key pair here.
  7. Set Up Security Group. Allow traffic on port 5678 (for n8n) and port 22 (for SSH).
  8. Review and Launch. Click on launch and wait for the instance to be ready.

Connect to Your Instance via SSH

Once your instance is set up, you need to connect via SSH. Use the following command:

ssh -i /path/to/your-key.pem ubuntu@your-ec2-public-ip

Replace /path/to/your-key.pem with the path to your key file and your-ec2-public-ip with your instance’s public IP address.

Install Docker & Docker Compose

Now, install Docker and Docker Compose. Use the following commands:

sudo apt update
sudo apt install -y docker.io
sudo systemctl start docker
sudo systemctl enable docker

# Install Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

Create the Docker Compose File for n8n

Next, create a docker-compose.yml file for n8n. Run:

nano docker-compose.yml

Add the following content to the file:

version: '3.1'

services:
  n8n:
    image: n8n/n8n
    environment:
      - N8N_HOST=your-n8n-domain-or-ip
      - N8N_PORT=5678
      - N8N_PROTOCOL=http
      - N8N_BASIC_AUTH_USER=your_user
      - N8N_BASIC_AUTH_PASSWORD=your_password
    ports:
      - 5678:5678
    volumes:
      - ~/.n8n:/home/node/.n8n

Make sure to replace your-n8n-domain-or-ip, your_user, and your_password with your desired settings.

Start the n8n Container

To start the n8n container, run the following commands:

docker-compose up -d

Check if n8n is running by visiting http://your-ec2-public-ip:5678 in your browser.

(Optional) Set Up Reverse Proxy & HTTPS

If you’re using a domain name, consider setting up a reverse proxy with NGINX and Certbot for SSL. This provides secure access to your n8n instance. Here’s a brief overview of how to do this:

  1. Install NGINX:
sudo apt install nginx
  1. Configure NGINX (with a file in /etc/nginx/sites-available/your-config-file):
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. Link Config and Start NGINX:
sudo ln -s /etc/nginx/sites-available/your-config-file /etc/nginx/sites-enabled/
sudo systemctl restart nginx
  1. Get SSL Certificate using Certbot:
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d your_domain.com

Maintenance & Security Tips

  • Set Up Firewall Rules: Configure your security group to restrict access.
  • Back Up Regularly: Use AWS’s backup solutions to keep your data secure.
  • Use Persistent Storage: Ensure data survival using Docker volumes or AWS EBS.
  • Update Automatically: Schedule Docker container updates when needed.

Conclusion

Setting up n8n on AWS with Docker is straightforward. Once your workflows are running, you’ll unlock new automation possibilities. Explore n8n’s capabilities and consider downloading prebuilt Docker Compose files if you need faster setups. If you need support, don’t hesitate to seek help from the community or consult documentation.

Ready to automate your workflows? Start setting up n8n today and transform how you work.

Frequently Asked Questions

n8n is an open-source workflow automation tool that connects various apps, allowing you to automate tasks without coding.

AWS provides scalable and flexible infrastructure, making it easy to deploy and manage n8n with reliability.

You need an AWS account, basic terminal skills, Docker, Docker Compose, and optionally a domain name.

You connect via SSH using the key pair you created when launching your instance.

Yes, n8n integrates with various tools, including HubSpot and Slack, making it easy to automate workflows.

Check the terminal output for error messages, or refer to the n8n and AWS documentation for troubleshooting tips.

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