Deploying Local Applications Using Cloudflared Tunnel¶
Overview¶
cloudflared
is a command-line tool provided by Cloudflare that establishes a secure tunnel between your local machine and the Cloudflare network. This allows developers to expose a local web service to the public internet without needing to open firewall ports, configure NAT, or obtain a static IP address. It is widely used to securely serve internal services, dashboards, or development websites over HTTPS using custom domain names.
This document provides a comprehensive step-by-step guide to deploying a local web application (such as a Dash dashboard) using Cloudflare Tunnel on a Windows machine, with a custom domain managed via Cloudflare DNS.
Prerequisites¶
- A registered domain name added to your Cloudflare account
- A local web service running (e.g., Dash app on
http://localhost:8050
) - Windows environment with administrative privileges
Step 1: Install cloudflared
¶
- Download
cloudflared
from the official Cloudflare site - Place
cloudflared.exe
in a known directory (e.g.,C:\cloudflared
) - (Optional) Add the directory to the system PATH variable for global command-line access
Step 2: Authenticate with Cloudflare¶
- A browser window will open prompting you to log in and select your domain
- On success, a
.cloudflared/.cert.pem
file will be generated atC:\Users\<YourUsername>\.cloudflared\.cert.pem
Step 3: Create a Tunnel¶
- This generates a unique Tunnel ID and corresponding credentials
.json
file
Step 4: Configure the Tunnel¶
Create a config.yml
file in:
Example:
Ensure paths are correctly quoted if they contain spaces.
Step 5: Route DNS to the Tunnel¶
- This command creates a DNS
CNAME
record pointing your subdomain to the tunnel
Step 6: Start the Tunnel¶
Option A: Temporary (development)¶
Option B: Persistent as a Windows Service¶
- This will run the tunnel automatically on system boot
- Alternatively, create a Task Scheduler entry to launch it on user login
Step 7: Verify Public Access¶
Visit:
If everything is configured correctly, you should see your local Dash app accessible over HTTPS.
Additional Recommendations¶
- Use
cloudflared tunnel info dash-tunnel
to verify tunnel health - Keep your Dash app auto-started with Docker's
--restart=always
flag - Use GitHub Pages + Cloudflare DNS together for static site hosting
- Consider implementing Basic Auth or Access Policies via Cloudflare Zero Trust for private dashboards
Summary¶
By combining cloudflared
, a local web service, and Cloudflare's secure global edge network, you can safely expose applications for development, collaboration, or even lightweight production use with minimal infrastructure and maximum security.