Skip to content

About

Docker compose deployment of n8n, including certificate, database and traefik

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

n8n Docker Compose Setup

A production-ready n8n setup using Docker Compose with Traefik reverse proxy, PostgreSQL database, and Let's Encrypt SSL certificates via Cloudflare DNS challenge.

Features

  • Automatic SSL certificates via Let's Encrypt (DNS-01 challenge with Cloudflare)
  • Traefik reverse proxy with automatic HTTPS redirect
  • PostgreSQL database for n8n workflows
  • Docker Compose for easy deployment
  • Production-ready configuration

Prerequisites

  • Docker and Docker Compose installed
  • A domain name configured in Cloudflare
  • Cloudflare API token with DNS edit permissions

Quick Start

  1. Clone the repository

    git clone git@github.com:sn1ce/docker-n8n.git
    cd docker-n8n
  2. Copy the example environment file

    cp .env.example .env
  3. Edit .env with your configuration

    nano .env

    Required values:

    • N8N_HOST: Your n8n subdomain (e.g., n8n.yourdomain.com)
    • LETSENCRYPT_EMAIL: Your email for Let's Encrypt notifications
    • CF_DNS_API_TOKEN: Your Cloudflare API token
    • POSTGRES_PASSWORD: Strong password for PostgreSQL
    • N8N_BASIC_AUTH_PASSWORD: Strong password for n8n access
  4. Start the stack

    docker compose up -d
  5. Access n8n

    • Navigate to https://your-n8n-host.com
    • Login with the credentials from your .env file

Cloudflare API Token Setup

  1. Go to Cloudflare Dashboard
  2. Click "Create Token"
  3. Use the "Edit zone DNS" template
  4. Restrict to your specific domain zone
  5. Copy the token to your .env file

Configuration

Environment Variables

All configuration is done via the .env file. See .env.example for all available options.

Traefik

Traefik is configured to:

  • Automatically redirect HTTP to HTTPS
  • Request SSL certificates via DNS-01 challenge
  • Route traffic to the n8n container

PostgreSQL

PostgreSQL is used as the database backend for n8n, providing better performance and reliability than SQLite.

Maintenance

View logs

docker compose logs -f

Restart services

docker compose restart

Update containers

docker compose pull
docker compose up -d

Backup database

docker compose exec postgres pg_dump -U n8n n8n > backup.sql

Security Notes

  • Never commit your .env file
  • Use strong passwords for all credentials
  • Keep your Cloudflare API token secure
  • Regularly update Docker images
  • Consider enabling Traefik dashboard authentication if needed

Troubleshooting

Certificate issues

  • Check Traefik logs: docker compose logs traefik
  • Verify Cloudflare API token has correct permissions
  • Ensure DNS records are properly configured

Database connection issues

  • Verify PostgreSQL is healthy: docker compose ps
  • Check database logs: docker compose logs postgres

n8n not accessible

  • Verify N8N_HOST matches your domain
  • Check Traefik routing labels in compose.yaml
  • Ensure ports 80 and 443 are open

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

Docker compose deployment of n8n, including certificate, database and traefik

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors