If you are looking for an automation tool, then n8n is for you. N8N, which is also known as “node everywhere node,” is an open-source tool that will help you in developing your own automation work. The best part of this tool is that you don’t even have to code; n8n offers you a graphical interface that you can use to automate your processes.
Here in this tutorial, I will tell you how to install and configure n8n on Ubuntu for both testing and production servers with Let’s Encrypt SSL.
In this tutorial, you will learn
Features of n8n
Gui-Based Editor – A Very simple drag and drop designer, using which you can configure a simple to highly complex automation system. You can easily edit nodes, add or remove any logic.
Lots of integrations – A Huge list of tools that you can connect to each other and make an awesome automation tool. Tools like GitHub, Slack, Google Sheets, MySQL, AWS, Trello, and many more.
Self-Hosting Support – You can host n8n on your own setup using Docker, which gives you full control over your setup.
Native JavaScript – All the JavaScript needed is available on your setup. You can even write your own JavaScript and add it anywhere you want, which gives you the freedom to inject your own functionality.
Robust Security – You can set up authentication, SSL, and also manage a granular level of permissions to safeguard the data, and this makes n8n highly suitable for a production-based environment.
Prerequisite
- A registered domain
- An Ubuntu VPS or bare-metal server
- User with root privileges
- Email ID for Let’s Encrypt SSL
Step 1 – Installing Docker on Ubuntu
The first step is to install Docker on Ubuntu, which will handle all our n8n-related processes.
# sudo apt update
# sudo apt install -y docker.io docker-composeStep 2 – Create an Environment for Docker
The second step is to set up the Docker environment and directory.
sudo mkdir ~/n8n
cd ~/n8nLet’s create a file that will have our setup’s configuration
sudo nano docker-compose.ymlversion: '3.7'
services:
db:
image: postgres:14
environment:
- POSTGRES_USER=n8n
- POSTGRES_PASSWORD=n8npass
- POSTGRES_DB=n8n
volumes:
- postgres_data:/var/lib/postgresql/data
n8n:
image: n8nio/n8n
ports:
- "5678:5678"
environment:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=db
- DB_POSTGRESDB_DATABASE=n8n
- DB_POSTGRESDB_USER=n8n
- DB_POSTGRESDB_PASSWORD=n8npass
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=admin
- N8N_BASIC_AUTH_PASSWORD=strongpass
- N8N_HOST=n8n.yourdomain.com
- WEBHOOK_TUNNEL_URL=https://n8n.yourdomain.com
depends_on:
- db
volumes:
- n8n_data:/home/node/.n8n
volumes:
postgres_data:
n8n_data:Note: Make sure to enter a strong password for “N8N_BASIC_AUTH_PASSWORD” and “DB_POSTGRESDB_PASSWORD“
Step 3 – Start n8n and test the Installation
The third step is to start the n8n service and test the installation.
# sudo docker-compose up -dNow, open any browser and enter http://your-ip-address:5678
Step 4 – Set up Nginx webserver for n8n
The fourth step is to set up the Nginx web server, which will handle n8n processes. So let’s install Nginx and certbot
# sudo apt install -y nginx certbot python3-certbot-nginxNow we will have to create our web server configuration file. You can choose among the files given below
# sudo nano /etc/nginx/sites-available/n8nNow, copy and paste the file given below as per your need
Option 1 – Testing server
If you are setting up n8n for testing purposes, use the below configuration
server {
listen 80;
server_name yourdomain.com;
location / {
proxy_pass http://localhost:8088;
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;
}
}Option 2 – Production Server
If you are setting up n8n for production use the below configuration
server {
listen 80;
server_name n8n.yourdomain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name n8n.yourdomain.com;
ssl_certificate /etc/letsencrypt/live/n8n.yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/n8n.yourdomain.com/privkey.pem;
location / {
proxy_pass http://localhost:5678; # Corrected port
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;
}
}Link the file in the sites-enabled directory
# sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/
# sudo nginx -tIf everything is good, restart the nginx service
# sudo systemctl restart nginxStep 5 – Configure Let’s Encrypt SSL on n8n
The fifth step is to configure Let’s Encrypt SSL.
sudo certbot –nginx -d n8n.yourdomain.com
Step 6 – Updating Firewall
Finally, make sure to update ufw firewall as per the configurations we have done above
# sudo ufw allow 80,443,5678Conclusion
With this, you have successfully configured n8n on Ubuntu. Now, just open the domain on any browser and continue the setup.
Leave a Reply