Khaled Ezzat

Mobile Developer

Software Engineer

Project Manager

Tag: Automation

16/07/2025 How to Self-Host n8n for Workflow Automation

If you’re diving into self-hosted automation, n8n is a solid choice. Here’s how I set it up on my home lab server using Docker Compose.

## Prerequisites
– A server with Docker and Docker Compose
– A domain name (optional but recommended)

## Step 1: Create the Docker Compose File
“`yaml
version: ‘3.7’
services:
n8n:
image: n8nio/n8n
restart: always
ports:
– ‘5678:5678’
environment:
– N8N_BASIC_AUTH_USER=admin
– N8N_BASIC_AUTH_PASSWORD=supersecretpassword
– N8N_HOST=n8n.example.com
– WEBHOOK_TUNNEL_URL=https://n8n.example.com
volumes:
– ./n8n_data:/home/node/.n8n
“`

## Step 2: Secure Your Instance with HTTPS
Use Traefik or Nginx as a reverse proxy. Hereโ€™s a simple Nginx config snippet:
“`nginx
server {
listen 443 ssl;
server_name n8n.example.com;

location / {
proxy_pass http://localhost:5678;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
“`

## Step 3: Run Your Container
“`bash
docker-compose up -d
“`

## Tips
– Use environment variables or `.env` file for secrets
– Set up backups for `./n8n_data`
– Use Cloudflare for DNS + SSL

## Final Thoughts
n8n has made it easy to automate tasks across services. Hosting it yourself gives you full control and privacy. Just keep it secure and updated!

> ๐Ÿง  Ready to start your self-hosted setup?
>
> I personally use [this server provider](https://www.kqzyfj.com/click-101302612-15022370) to host my stack โ€” fast, affordable, and reliable for self-hosting projects.
> ๐Ÿ‘‰ If you’d like to support this blog, feel free to sign up through [this affiliate link](https://www.kqzyfj.com/click-101302612-15022370) โ€” it helps me keep the lights on!