đ Cloudflare Tunnel Setup Guide
Securely expose your local services to the internet without port forwarding
Prerequisites
- Ubuntu/Debian Linux system with sudo access
- Active Cloudflare account with domain management
- Domain or subdomain managed by Cloudflare DNS
- Local service running (we'll use port 80 in this guide)
- Basic command line knowledge
Install cloudflared
Download and install the latest cloudflared package for Linux AMD64 systems. This tool creates secure tunnels between your server and Cloudflare's edge network.
Authenticate with Cloudflare
Authenticate cloudflared with your Cloudflare account. This command will open a browser window where you'll log in to authorize the tunnel creation.
Create a New Tunnel
Create a new tunnel with a descriptive name. This establishes a persistent connection identifier that Cloudflare will use to route traffic to your server.
~/.cloudflared/
. You can customize the tunnel name to match your project or service.
Configure Tunnel Routing
Create the configuration directory and file that defines how incoming traffic should be routed to your local services. This YAML configuration maps your domain to local services.
Configure DNS Routing
Create a DNS record that points your domain to the tunnel. This command automatically adds the necessary CNAME record to your Cloudflare DNS settings.
Install and Start Service
Install cloudflared as a system service so it runs automatically on boot and restarts if it fails. This ensures your tunnel remains available even after server reboots.
Verify Your Setup
Test your tunnel configuration and troubleshoot any issues. These commands help you monitor the service status and verify connectivity.