Skip to main content

Overview

n8n is a powerful workflow automation platform that allows you to connect various services and applications to create automated workflows. This document covers the deployment and configuration of n8n using Docker Compose with Traefik as a reverse proxy.

Service Details

Architecture

n8n is deployed as a multi-container application with the following components:
  • n8n: Main application container serving the workflow editor and execution engine
  • PostgreSQL: Database for storing workflows, credentials, and execution data

Prerequisites

  • Docker Engine (24.0+)
  • Docker Compose v2
  • Traefik reverse proxy configured and running
  • External networks: traefik-net and n8n-net
  • DNS configured for automations.trymondo.com
  • SMTP credentials for email notifications

Deployment Configuration

Environment Variables

Create a .env file with the following variables:
Generate a secure, random string for N8N_ENCRYPTION_KEY. This is used to encrypt credentials and sensitive data.
You can generate a secure random string with: bash openssl rand -hex 16

Docker Compose File

Network Configuration

Before deployment, ensure the required networks exist:

Deployment Instructions

  1. Create the deployment directory structure:
  2. Create the configuration files:
  3. Deploy the service:
  4. Verify the services are running:
  5. Access n8n at https://automations.trymondo.com and log in with the credentials specified in the .env file.

Traefik Integration

n8n is configured with the following Traefik settings:
  • Host Rule: automations.trymondo.com
  • Entrypoint: websecure (HTTPS)
  • TLS: Enabled with production certificate resolver
  • Backend Port: 5678
  • Middlewares: Rate limiting and secure headers

Configuration Highlights

Security Configuration

n8n is configured with several security features:
  • Basic Authentication: Requires username/password to access the UI
  • Encryption Key: All sensitive data is encrypted at rest
  • HTTPS: All traffic is encrypted via Traefik
  • Rate Limiting: Prevents brute force attacks

Workflow Execution Settings

The n8n instance is configured with the following execution settings:
  • Regular Execution Mode: Workflows run in the main process
  • Data Retention: Error execution data is saved, successful executions are not
  • Data Pruning: Old execution data is automatically removed after 336 hours (14 days)
  • Runners Enabled: Allows distributed workflow execution

Email Notifications

Email is configured using SMTP with the following settings:

Maintenance

Backup Strategy

Back up n8n regularly using the following commands:

Updates

To update n8n:
  1. Update the image tag in docker-compose.yml
  2. Apply the update:
  3. Check logs for any issues:
Always back up your data before updating n8n to a new version.

Troubleshooting

Database Connection Issues

If n8n can’t connect to the database:
  1. Verify PostgreSQL container is running:
  2. Check database logs:
  3. Verify credentials in .env file match what n8n is using

Webhook Issues

If webhooks are not working correctly:
  1. Verify the webhook URL configuration:
  2. Check that the URL is accessible from the internet
  3. Verify Traefik is properly routing requests

Authentication Problems

If you’re having trouble logging in:
  1. Check the basic auth settings:
  2. Reset the admin password by updating the .env file and restarting the container

Example Workflows

Webflow Form to Mautic Integration

This workflow captures form submissions from Webflow and adds contacts to Mautic:
  1. Create a webhook node as the trigger
  2. Copy the webhook URL to your Webflow form’s action URL
  3. Add a Mautic node to create/update contacts
  4. Configure the mapping between Webflow form fields and Mautic contact fields

Daily Database Backup Notification

This workflow creates and notifies about database backups:
  1. Set up a Cron node to trigger daily at a specific time
  2. Add an Execute Command node to run pg_dump
  3. Add a Send Email node to notify about successful backups
  4. Add error handling to notify about failures

Security Considerations

  • Credential Storage: All API credentials are encrypted using the N8N_ENCRYPTION_KEY
  • Basic Authentication: The UI is protected with username/password
  • HTTPS: All traffic is encrypted via Traefik
  • Database Security: The PostgreSQL database is not exposed outside the Docker network
  • Execution Data: Only error execution data is saved to reduce sensitive data exposure

Additional Resources

Integration with Other Mondo Services

n8n can be integrated with other Mondo services:
  • Mautic: Use the Mautic nodes to manage contacts and campaigns
  • EspoCRM: Use HTTP Request nodes or custom nodes to interact with the CRM API
  • Gitea: Use Webhook triggers for repository events
  • Traefik: Ensure proper routing and HTTPS termination