Download and install the latest cloudflared package for Linux AMD64 systems. This tool creates secure tunnels between your server and Cloudflare's edge network.
This downloads the .deb package directly from GitHub and installs it using apt. The cloudflared binary will be available system-wide after installation.
Authenticate cloudflared with your Cloudflare account. This command will open a browser window where you'll log in to authorize the tunnel creation.
cloudflared tunnel login
โ ๏ธ
Authentication Method
When the browser opens, use "Continue with Google" if that's how you normally access your Cloudflare account. Make sure you're logged into the correct Cloudflare account that manages your domain.
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 tunnel create thelab-tunnel
๐ก
Tunnel Credentials
This creates a tunnel and generates a unique credentials file stored in ~/.cloudflared/. You can customize the tunnel name to match your project or service.
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.
Replace your-subdomain.your-domain.com with your actual domain or subdomain. Ensure this domain is managed by Cloudflare DNS and you have the necessary permissions.
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.
sudo cloudflared service install
sudo systemctl enable --now cloudflared
๐
Service Active
Your tunnel is now running as a system service and will automatically start when your system boots. The service is managed by systemd for reliability.
Test your tunnel configuration and troubleshoot any issues. These commands help you monitor the service status and verify connectivity.
# Check service status
sudo systemctl status cloudflared
# View live logs
sudo journalctl -u cloudflared -f
# Test the tunnel connection
curl -I https://your-subdomain.your-domain.com
# Check tunnel list
cloudflared tunnel list
๐
Setup Complete!
Your local service running on port 80 should now be accessible via your Cloudflare domain with automatic HTTPS, DDoS protection, and global CDN benefits.