A Docker-based setup for running n8n locally with nginx as a reverse proxy and ngrok for exposing webhooks to the internet.
This project provides a complete, production-ready n8n workflow automation environment:
- n8n — Workflow automation platform
- nginx — Reverse proxy in front of n8n (port 80)
- ngrok — Exposes the local instance via a public HTTPS URL for webhooks and external integrations
Data is persisted in Docker volumes, and workflows/credentials can be backed up to the n8n-data/ directory.
Copy .env.example to .env and configure the following variables:
| Variable | Description |
|---|---|
NGROK_AUTHTOKEN |
Your ngrok authentication token. Required for the ngrok container to tunnel traffic. |
SUBDOMAIN |
Your ngrok reserved domain (e.g. my-app.ngrok-free.dev). Used for the public webhook URL. |
N8N_ENCRYPTION_KEY |
Secret key used by n8n to encrypt credentials in the database. Use a strong, unique value in production. |
WEBHOOK_URL |
Base URL for n8n webhooks. Typically https://${SUBDOMAIN} so webhooks use your ngrok domain. |
- Docker and Docker Compose
- An ngrok account and reserved domain (for webhooks)
cp .env.example .envEdit .env and set:
NGROK_AUTHTOKEN— from your ngrok dashboardSUBDOMAIN— your ngrok domain (e.g.my-app.ngrok-free.dev)N8N_ENCRYPTION_KEY— a strong random string
make upThis builds and starts the containers, then follows logs. Press Ctrl+C to stop following logs; containers keep running.
- Local: http://localhost
- Public (webhooks): https://your-subdomain.ngrok-free.dev
Export all workflows and credentials to n8n-data/:
make exportCreates:
n8n-data/workflows_all.json— all workflowsn8n-data/credentials_all.json— all credentials (encrypted withN8N_ENCRYPTION_KEY)
Import from the backup files in n8n-data/:
make importImports:
- Workflows from
n8n-data/workflows_all.json - Credentials from
n8n-data/credentials_all.json
Note: Use the same N8N_ENCRYPTION_KEY as when the credentials were exported, or decryption will fail.
You can also run n8n CLI commands directly inside the container:
# Export workflows
docker compose exec n8n n8n export:workflow --all --output=/home/node/n8n-data/workflows_all.json
# Export credentials
docker compose exec n8n n8n export:credentials --all --output=/home/node/n8n-data/credentials_all.json
# Import workflows
docker compose exec n8n n8n import:workflow --input=/home/node/n8n-data/workflows_all.json
# Import credentials
docker compose exec n8n n8n import:credentials --input=/home/node/n8n-data/credentials_all.json| Command | Description |
|---|---|
make help |
Show available commands |
make up |
Start containers and follow logs |
make logs |
Start containers logs |
make down |
Stop all containers |
make downv |
Stop containers and remove volumes (deletes all data) |
make export |
Export workflows and credentials to n8n-data/ |
make import |
Import workflows and credentials from n8n-data/ |