Introduction
Automating workflows has become an essential part of modern businesses, and n8n is a powerful, self-hostable automation tool that simplifies the process. In this guide, we'll walk you through setting up n8n on a DigitalOcean Droplet using Docker and Caddy, ensuring a secure and efficient deployment.
Prerequisites
Before we begin, make sure you have the following:
- A DigitalOcean account
- Basic knowledge of Linux commands
- Domain and subdomain ready for your setup
Step 1: Create a DigitalOcean Droplet
- Log in to your DigitalOcean account.
- Select a project or create a new one.
- Navigate to Manage > Droplets > Create Droplet.
- Choose the Docker image from the Marketplace tab.
- Select a plan based on your resource requirements (Basic Shared CPU plan is usually sufficient).
- Finalise your Droplet setup and note the IP address.
Step 2: Secure Your Droplet
Log in to your new Droplet via SSH:
ssh root@<Your-Droplet-IP>
Create a new user for managing n8n:
adduser <USERNAME>
usermod -aG sudo <USERNAME>
Log out and log back in as the new user:
ssh <USERNAME>@<Your-Droplet-IP>
Step 3: Clone the n8n Docker Repository
Clone the n8n Docker setup with Caddy:
git clone https://github.com/n8n-io/n8n-docker-caddy.git
cd n8n-docker-caddy
Step 4: Create Docker Volumes
Set up persistent storage for Caddy and n8n:
sudo docker volume create caddy_data
sudo docker volume create n8n_data
Step 5: Configure Firewall
Allow HTTP and HTTPS traffic:
sudo ufw allow 80
sudo ufw allow 443
Step 6: Update Environment Variables
Create or update your .env
file:
DATA_FOLDER=/home/<USERNAME>/n8n-docker-caddy
SUBDOMAIN=n8n
DOMAIN=yourdomain.com
GENERIC_TIMEZONE="Asia/Kuala_Lumpur"
Replace <USERNAME>
and yourdomain.com
with your user and domain details.
Step 7: Update Caddyfile
Open caddy_config/Caddyfile
and add your subdomain configuration:
n8n.yourdomain.com {
reverse_proxy n8n:5678 {
flush_interval -1
}
}
Save and close the file.
Step 8: Start Docker Containers
Bring up the containers:
sudo docker-compose up -d
Step 9: Access n8n
Open your browser and navigate to:
https://n8n.yourdomain.com
You should now see the n8n interface.
Conclusion
Congratulations! You've successfully deployed n8n on DigitalOcean using Docker and Caddy. With this setup, you can now start building and managing your automation workflows efficiently.
For more details and troubleshooting, refer to the n8n documentation.
Photo by Codioful (Formerly Gradienta) on Unsplash
Top comments (0)