Cloudflare Tunnel

Cloudflare Tunnel
shamelessly copied from Cloudflare Tunnel · Cloudflare Zero Trust docs

Premise

In a previous post, I discussed how I exposed my local network’s traffic without a static IP address (Start of self hosted server). However, recently, this site is down, probably because the Tailscale session is expired.

Coincidentally, I discovered a better solution to this problem

Enter Cloudflare Tunnel

Despite having read about Cloudflare Tunnel before, it didn’t fully click until I stumbled upon a YouTube video titled Every Developer Needs a Raspberry Pi Then, I realized how easy and straightforward it is to expose my local services to the internet using Cloudflare Tunnel — even without relying on my Linode public IP address.

the other part of video is also good btw

The migration

The best part? I completed the entire migration in just a few minutes. Here’s what I did:

Install Cloudflared:

I followed the installation instructions on GitHub to set up Cloudflared on my local machines

Create a Cloudflare Tunnel:

Using the guide Create a Remotely-Managed Tunnel from Cloudflare, I created a tunnel that redirects all traffic to http://localhost:80. I also need to remove all existing A Record from DNS management.

Untitled
note that wildcard subdomain will need me to manually update the CNAME records

Copy Existing Routing Rules:

Transfer all my existing routing rules from Caddy on my public VM to Caddy running on my local machines using scp -r root@l-sg-0:/srv/caddy /srv.

Voilà! My site was back up, and the best part. No more worrying about refreshing Tailscale tokens to keep things working smoothly.