This repository contains a Docker Compose setup for running n8n with Cloudflare as a tunneling service. n8n is a workflow automation tool that allows you to connect different services and APIs. Cloudflared exposes local servers behind NATs and firewalls to the public internet over secure tunnels.
Before you begin, ensure you have the following configured:
- Docker: Get Docker
- Docker Compose: Install Docker Compose
- Cloudflare Account
-
Clone the Repository
Clone this repository to your local machine:
git clone https://github.com/joffcom/n8n-cloudflare.git
-
Cloudflare Configuration
- Access the Tunnel configuration page in Cloudflare under Zero Trust > Networks > Tunnels
- Click Create Tunnel and select
Cloudflared
as the Connector - Give your tunnel a name, This name is used for you to identify the tunnel and won't be part of the domain
- Copy your access token and put it in the
.env
file replacingyour_tunnel_token
- Configure your subdomain place this in the
.env
file replacinghttps://n8n.your-domain.com
- For the Service select
http
and set the url ton8n:5678
this is used for the tunnel routing.
-
Configure n8n
Optionally, you can configure n8n by modifying environment variables in the
docker-compose.yml
file under then8n
service.
To run n8n with Cloudflare, use the following command:
docker compose up -d
This command will start both n8n and Cloudflared services. Cloudflared will provide a URL that tunnels to your n8n instance.
After running the Docker Compose command you can access n8n by navigating to the URL configured in Cloudflare in your web browser.
To stop the n8n and Cloudflared services, use:
docker compose down