Table of Contents
  • Home
  • /
  • Blog
  • /
  • Step-by-Step Procedure to Set Up TryCloudflare to Access Your Local Application Over the Internet
January 3, 2024
|
8m

Step-by-Step Procedure to Set Up TryCloudflare to Access Your Local Application Over the Internet


Step By Step Procedure To Set Up Trycloudflare To Access Your Local Application Over The Internet

Developers often need to access their locally running applications over the internet during development and testing. Whether you are building a new web app or troubleshooting issues in an existing one, having the ability to easily share your local environment with team members and testers is invaluable.

Traditionally, publishing a locally running app on the public internet required configuring port forwarding on your router or using tunneling software like ngrok. These options can be complex to set up and often come with limitations.

In this post, well explore how to leverage Cloudflare’s TryCloudflare service to seamlessly Set Up TryCloudflare to Access Your Local Application Over the Internet. With just a few commands, you can instantly Make private site public using cloudflared. Read on to learn how to easily Host a localhost service on the internet using TryCloudflare.

What is Required to Host a Localhost Service on the Internet?

In general, publishing a locally running web server on the public internet requires:

  • A public IP address Your local machine likely uses a private IP address behind a router, so you need a way to expose it publicly.

  • Port forwarding Opening a port on your routers firewall and forwarding traffic from that port to your local web servers port.

  • A domain name To route traffic to your public IP address in a human-readable way.

  • TLS/SSL encryption Traffic should be encrypted for security, requiring SSL certificates.

  • Client configuration Any clients need to know how to reach your services new public location.

Setting all this up requires networking expertise and control over infrastructure like routers and DNS records. The process differs across operating systems and network configurations. Maintenance like certificate renewals adds overhead.

Tools like ngrok simplify aspects of this process through their tunneling and orchestration capabilities. But they come with restrictions on usage, features, and traffic volumes in their free tiers.

This highlights the need for a frictionless way to Host a localhost service on the internet using TryCloudflare that abstracts away these complexities and limitations.

What is TryCloudflare?

TryCloudflare is a service from Cloudflare that provides free, instant, and unlimited public access to web servers and sites running on your local machine.

With just a single command, TryCloudflare will spin up a Cloudflare Tunnel to your localhost and generate a random public subdomain on the trycloudflare.com domain. Traffic to this auto-generated subdomain is seamlessly routed through Cloudflare’s network to your local web server.

Some key capabilities provided by TryCloudflare include:

  • Instant setup Get a public URL to your localhost in seconds, without configuring DNS records, certificates, port forwarding or public IPs.

  • Unlimited traffic No restrictions on bandwidth or number of requests, unlike some tunneling tools.

  • Global availability TryCloudflare tunnels leverage Cloudflare’s 200+ data centers for low latency worldwide access.

  • HTTPS encryption Traffic is encrypted end-to-end by default for security.

  • Web app firewall Cloudflares WAF protects your origin from exploits and attacks.

  • Argo Smart Routing Improves performance with dynamic path optimization and peering.

  • Simple CLI The cloudflared daemon and command-line interface make TryCloudflare easy to use.

  • No login required Get started immediately without a Cloudflare account.

In summary, TryCloudflare simplifies the process of Publish local projects with cloudflared by handling all the complex networking and security requirements for you.

How Does TryCloudflare Work?

Under the hood, TryCloudflare relies on two Cloudflare technologies: Cloudflare Tunnel and the Cloudflare virtual network.

The Cloudflare Tunnel client (cloudflared) runs locally on your machine as a daemon or service. When you invoke TryCloudflare, cloudflared will establish an outbound-only connection from your machine to the nearest Cloudflare data center.

This creates a secure Tunnel that encapsulates traffic and hands it off to Cloudflares network. No incoming ports need to be opened on your local firewall. cloudflared registers the Tunnel with a randomly generated UUID subdomain under trycloudflare.com.

Inside the Cloudflare network, incoming requests addressed to this subdomain are routed through the Tunnel to your origin web server running locally. As traffic leaves Cloudflare to your machine, it passes through the Cloudflare Web Application Firewall for inspection. This protects your local machine from web-based attacks.

The Cloudflare virtual network globally load balances and optimizes connectivity between data centers. Your tunnel takes advantage of Argo Smart Routing and other performance enhancements as traffic flows through Cloudflares network.

Locally, cloudflared proxies web traffic arriving from the Tunnel to your web server running on localhost. This could be a Node.js app listening on port 8000, for example. The TryCloudflare architecture keeps your machine hidden behind Cloudflares network.

In summary, TryCloudflare provides a direct, secure tunnel from a public URL to your localhost service, bypassing the need to configure DNS records, firewall rules, TLS certificates, and more. The setup process takes just seconds.

Prerequisites to Set Up TryCloudflare

TryCloudflare has minimal requirements, given all the complexity it abstracts away. Heres what you need:

  • The cloudflared daemon installed on your local machine.

  • An active web server or application listening on localhost.

  • An internet connection.

Thats it! Theres no need for a Cloudflare account or login. And cloudflared can be installed quickly using package managers like apt, brew, or choco depending on your operating system.

Lets walk through how to get set up on an Ubuntu Linux machine. Well assume you have a web server running on port 8000 locally that you want to share.

How to Set Up TryCloudflare to Access Your Local Application Over the Internet?

Follow these steps to start routing traffic to your local web server through a TryCloudflare tunnel:

Step 1. Install Cloudflare

On Ubuntu, we can install the cloudflared daemon using apt. Follow these commands to install on Ubuntu.

# Add cloudflare gpg key
sudo mkdir -p --mode=0755 /usr/share/keyrings
curl -fsSL https://pkg.cloudflare.com/cloudflare-main.gpg | sudo tee /usr/share/keyrings/cloudflare-main.gpg >/dev/null


# Add this repo to your apt repositories
echo 'deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared jammy main' | sudo tee /etc/apt/sources.list.d/cloudflared.list


# install cloudflared
sudo apt-get update && sudo apt-get install cloudflared

If you want to install cloudflared on other other popular Linux distributions like RedHat,
CentOS, Debian, or Amazon Linux, check out here.

If you want to download and install on other platforms like Windows and macOS, check out
here.

Step 2. Verify the installation of Cloudflare

Run this version check command to verify the installation of cloudflared:

cloudflared --version

Step 3. Start your local web server

You can run your application on Apache, Nginx, npm, or any web server. You need to make sure your service is running on localhost.

In this demo, we have installed the Splunk Enterprise server on our local machine. We access Splunk at http://localhost:8000.

Step 4. Initiate a TryCloudflare tunnel

Run the following command in your terminal, replacing localhost:8000 with your apps origin:

cloudflared tunnel --url localhost:8000

This will
establish a Cloudflare Tunnel between your machine and Cloudflares network.

https://ships-invision-green-potter.trycloudflare.com

Step 5. Use the generated subdomain to access your local service over the internet

The output from the cloudflared the command will include a unique subdomain on trycloudflare.com that now points to your local web server:

Visit this URL in your browser and you should see your web app served through the tunnel!

Feel free to share the URL with anyone you want them to access. Traffic to that subdomain will be routed to your dev environment. No more port forwarding hassles!

https://ships-invision-green-potter.trycloudflare.com

Thats all it takes to get any web application or API running locally exposed to the public web in just seconds. The tunnel and subdomain will remain active as long as cloudflared keeps running.

Wrapping Up

In this post, we walked through how to instantly Host a localhost service on the internet using TryCloudflare. With just the cloudflared tool installed locally and a web server running, you can generate a public URL that securely routes traffic to your local environment.

TryCloudflare makes it incredibly easy to:

  • Let team members and testers access your local development work

  • Conduct performance testing from multiple regions

  • Gather feedback on work-in-progress projects

and more. Both developers and operations teams can benefit from TryCloudflare as it takes the headache out of exposing internal services for shared access.

We barely scratched the surface of Cloudflare Tunnels capabilities and integrations here. For more robust usage, Cloudflare provides 1-click app installs, custom hostnames, and integration with other Cloudflare tools like Access for authentication. Consider exploring TryCloudflare as an easy way to kick the tires on Cloudflares edge network.

So next time you need to make your private site public using cloudflared, turn to TryCloudflare for an instant, unlimited, and secure tunnel to your localhost. No networking expertise is required!

We hope this post helps you learn how to leverage Cloudflares TryCloudflare service to seamlessly Set Up TryCloudflare to Access Your Local Application Over the Internet. Visit our website, thesecmaster.com, and social media pages on Facebook, LinkedIn, Twitter, Telegram, Tumblr, & Medium and subscribe to receive updates like this.

Arun KL

Arun KL is a cybersecurity professional with 15+ years of experience in IT infrastructure, cloud security, vulnerability management, Penetration Testing, security operations, and incident response. He is adept at designing and implementing robust security solutions to safeguard systems and data. Arun holds multiple industry certifications including CCNA, CCNA Security, RHCE, CEH, and AWS Security.

Recently added

Application/Appliance

View All

Learn More About Cyber Security Security & Technology

“Knowledge Arsenal: Empowering Your Security Journey through Continuous Learning”

Cybersecurity All-in-One For Dummies - 1st Edition

"Cybersecurity All-in-One For Dummies" offers a comprehensive guide to securing personal and business digital assets from cyber threats, with actionable insights from industry experts.

Tools

Featured

View All

Learn Something New with Free Email subscription

Subscribe

Subscribe