Skip to content

Instantly share code, notes, and snippets.

@jimfaster
Created July 2, 2025 01:33
Show Gist options
  • Select an option

  • Save jimfaster/127866d25eb36e25c324416ceea7b33e to your computer and use it in GitHub Desktop.

Select an option

Save jimfaster/127866d25eb36e25c324416ceea7b33e to your computer and use it in GitHub Desktop.
Mind map for YouTube video: How to Set Up a Cloudflare Tunnel for Local n8n (2025)

How to Set Up a Cloudflare Tunnel for Local n8n (2025)

TL;DR

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.


Detailed Summary

  1. 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.
  2. 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."
  3. 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:5678 as the service.
  4. 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.
  5. 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 to https.
    • Restart the Docker container (docker compose down followed by docker compose up -d) to apply changes.
  6. 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.
  7. Troubleshooting Tips

    • Suggests using AI tools for terminal command assistance if issues arise during container restart.
  8. Conclusion

    • Reiterates the simplicity of the setup despite initial complexity and encourages viewers to like the video if helpful.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment