[EP.1] เข้าถึง n8n ได้ทุกที่ง่ายๆ ด้วย Cloudflare Tunnel | Step by Step Tutorial ภาษาไทย
Table of Contents
Introduction
In this tutorial, we will learn how to access n8n from anywhere in the world using Cloudflare Tunnel. This step-by-step guide is designed for those who have already set up n8n with Docker, as discussed in Episode 0. By the end of this tutorial, you will have n8n running online securely and ready for workflow automation.
Step 1: Setting Up Cloudflare Account
-
Create a Cloudflare Account
- Visit Cloudflare and sign up for a free account.
- Verify your email and log into your new Cloudflare account.
-
Add a Domain
- If you don’t have a domain, you can register one. A suggested starting place is this domain registrar.
- Follow the prompts to add a domain to your Cloudflare account.
-
Configure DNS Settings
- After adding the domain, access the DNS settings in your Cloudflare dashboard.
- Add a new DNS record for your n8n instance.
- Type: A
- Name:
n8n
(or any subdomain you prefer) - Value: Your server’s IP address.
- TTL: Auto.
Step 2: Install Cloudflare Tunnel
-
Install Cloudflare Tunnel
- Open your terminal.
- Run the following command to install the Cloudflare Tunnel:
curl -sSL https://raw.githubusercontent.com/cloudflare/cloudflared/main/install.sh | sudo bash
-
Authenticate Cloudflare Tunnel
- Run the command to authenticate:
cloudflared tunnel login
- Follow the prompts to complete the authentication process.
- Run the command to authenticate:
Step 3: Create a Tunnel for n8n
-
Create the Tunnel
- Execute the following command to create a new tunnel:
cloudflared tunnel create n8n-tunnel
- Note the tunnel ID that is generated.
- Execute the following command to create a new tunnel:
-
Configure Tunnel Route
- Create a configuration file by running:
nano ~/.cloudflared/config.yml
- Add the following configuration:
tunnel: YOUR_TUNNEL_ID credentials-file: /path/to/your/credentials-file.json ingress: - hostname: n8n.YOUR_DOMAIN service: http://localhost:5678 - service: http_status:404
- Replace
YOUR_TUNNEL_ID
andYOUR_DOMAIN
with your actual tunnel ID and domain.
- Create a configuration file by running:
Step 4: Start the Tunnel
- Run the Tunnel
- Run the following command to start the tunnel:
cloudflared tunnel run n8n-tunnel
- This command will keep the tunnel active, allowing you to access n8n remotely.
- Run the following command to start the tunnel:
Tips and Common Pitfalls
- Firewall Settings: Ensure your firewall allows traffic on the port used by n8n (default is 5678).
- Domain Propagation: It may take some time for your DNS settings to propagate. Be patient if you cannot access n8n immediately.
- Secure Your Instance: Consider implementing security measures like basic authentication within n8n to protect your workflows.
Conclusion
By following these steps, you have successfully set up Cloudflare Tunnel for your n8n instance, enabling remote access. This setup not only makes your workflows accessible from anywhere but also enhances security. As a next step, explore creating automated workflows in n8n to streamline your tasks further.