This video demonstrates how to set up a Cloudflare tunnel for a locally hosted n8n instance, enabling secure communication with third-party apps like Google or Telegram. The process begins by acquiring a public domain through Cloudflare, either by purchasing one or using an existing one. The tutorial then guides viewers through creating a Cloudflare tunnel, installing the connector locally, and configuring the tunnel to route traffic from a public HTTPS domain to the local n8n instance running on port 5678. A key step involves updating the Docker Compose file to include environment variables for the webhook URL and protocol (HTTPS), ensuring external services can properly interact with n8n. After restarting the Docker container, the setup allows seamless access to the n8n instance via the public domain, resolving previous limitations with localhost-based webhooks. The video emphasizes the tunnel's role in bypassing firewall restrictions, providing a secure and permanent public URL for local services.
-
Introduction
- The video explains how to use a Cloudflare tunnel to expose a locally hosted n8n instance to third-party services, overcoming firewall restrictions.
- Highlights the need for a public domain (purchased or transferred to Cloudflare) for a permanent solution, contrasting with temporary URLs from services like Ngrok.
-
Setting Up the Tunnel
- Navigate to Cloudflare Zero Trust > Networks > Tunnels and create a new tunnel (e.g., "n8n-test").
- Install the Cloudflare connector locally (Windows/Mac/Docker) and verify the tunnel status is "healthy."
-
Configuring the Public Hostname
- Add a public hostname (e.g.,
n8n.techcorp.org) in the tunnel settings. - Route traffic to the local n8n instance by specifying
http://localhost:5678as the service.
- Add a public hostname (e.g.,
-
How the Tunnel Works
- Illustrates the tunnel's role: External services (e.g., Gmail, Telegram) send data to the public domain, which Cloudflare securely forwards to the local n8n instance via the tunnel.
-
Updating n8n for Webhooks
- Modify the Docker Compose file to include:
WEBHOOK_URL: Set to the public domain (e.g.,https://n8n.techcorp.org/).N8N_PROTOCOL: Set tohttps.
- Restart the Docker container (
docker compose downfollowed bydocker compose up -d) to apply changes.
- Modify the Docker Compose file to include:
-
Verification and Use Cases
- Confirm the n8n instance is accessible via the public URL, with webhooks now using the HTTPS address.
- Enables integration with services like Google Drive, which require valid redirect URLs.
-
Troubleshooting Tips
- Suggests using AI tools for terminal command assistance if issues arise during container restart.
-
Conclusion
- Reiterates the simplicity of the setup despite initial complexity and encourages viewers to like the video if helpful.