Share your localhost with Cloudflare tunnels
Sean Boult

Sean Boult @hacksore

About: I use neovim btw

Location:
Texas
Joined:
Mar 10, 2022

Share your localhost with Cloudflare tunnels

Publish Date: Jun 10 '22
45 7

From time to time you'll want to share your locally running app with some folks before it's ready to ship.

Features

🤑 Free to use
💎 Not heavily rate limited
🔒 HTTPS support
🌎 Won't expose your IP

First make sure you have cloudflared installed and setup. You can check out the cloudflared docs for setup instructions.

Now we can create our first tunnel by running the following command.

cloudflared tunnel create mycoolapp
Enter fullscreen mode Exit fullscreen mode

Create a custom subdomain entry with ease just by running this command.

cloudflared tunnel route dns mycoolapp demo.boult.me
Enter fullscreen mode Exit fullscreen mode

Once your app is running you can expose it via the tunnel.

cloudflared tunnel --url http://localhost:8080 run mycoolapp
Enter fullscreen mode Exit fullscreen mode

Now you or a friend can visit the subdomain setup in one of the prior steps.

Image description

Comments 7 total

  • Joe Steinbring
    Joe SteinbringJun 10, 2022

    That's kind of cool. I'm using a dynamic dns service and a handful of open ports right now to do the same basic thing. Cloudflare Tunnel sounds like a sounder (and cheaper) alternative. :)

  • Ben Sinclair
    Ben SinclairJun 10, 2022

    There are a lot of services that do this, like localtunnel for example, which don't require you to do any weird setup involving "zero trust dashboards" or creating "applications".

    I'm not sure how the DNS resolution in this is supposed to work - in your example, you're mapping to demo.boult.me but presumably you have to set that with a CNAME to something inside Cloudflare first.

    • Sean Boult
      Sean BoultJun 10, 2022

      I agree that there are less complicated solutions like ngrok or localtunnel that can achive the same thing but if you already use cloudflare it's another option to try out.

      When you login to cloudflared CLI you select a domain on your account to use. The second command will create the CNAME for you but you can manually configure it AFAIK.

      Configure the CNAME manually

      CNAME demo.boult.me <uuid>.cfargotunnel.com
      
      Enter fullscreen mode Exit fullscreen mode
      • Ben Sinclair
        Ben SinclairJun 11, 2022

        Ah, so you need to have a domain managed by Cloudflare already, gotcha.

  • IroncladDev
    IroncladDevJun 10, 2022

    Whoah! Thank you so much for this! Now I can share my localhost without fear of my ip being leaked!!

  • Max F. Findel
    Max F. FindelJun 12, 2022

    This is awesome, I use cloudflare a lot and I didn't know this existed!

  • Matt Tunney
    Matt TunneyJun 12, 2022

    Very nice. Gonna try this on Monday.

Add comment