DEV Community

Cover image for Cloudflare Tunnels VS ngrok
Amjad Abujamous
Amjad Abujamous

Posted on • Updated on

Cloudflare Tunnels VS ngrok

TL;DR

Reverse proxy solutions are a great and straightforward method to expose your dev (and possibly production) server to the internet. The two prominent ones are ngrok and Cloudflare tunnels. This article recommends both of them and compares and contrasts them on a high level.

Introduction

As mentioned in my previous article, one can monitor their server using one of many solutions, and in order to expose your web or home server without opening a port on your firewall and possibly having to configure a static public IP, you need to use a reverse proxy solution to solve that problem. The two most reliable ones in the market at the time of writing this article are ngrok and Cloudflare Tunnels.

ngrok

Ngrok is the one that pops up the most in YouTube videos and online articles since it quite easy to setup and get up and running. The steps can be found here which include running a simple web server, installing ngrok, configuring the auth token, and running the reverse proxy agent.

Cloudflare tunnels

To run the cloudflared tunnel agent and have one up and running, you need to follow these steps:

  1. Create an account with Cloudflare by going to their website here and choosing the free plan.
  2. Fill up the information needed, which are an email address and a password at the time of writing this article.
  3. It will then take you to their dashboard where you need to do two things, register, link, or transfer a domain, and then create a tunnel in their Zero Trust dashboard. The screenshots below explain the steps.

3.1 Cloudflare domain
Cloudflare active domain

3.2 Cloudflare dashboard w/ ZeroTrust tab
Cloudflare dashboard w/ zero trust tab

3.3 Cloudflare tunnel creation steps
Note: The cloudflared client is easy to install yet its installation steps are different based on your operating system.
Cloudflare tunnel creation steps

3.4 Cloudflare active tunnel
Cloudflare active tunnel

My biased thoughts on the two solutions

As stated earlier, both solutions are reliable and they work well.

My preference is to use ngrok for dev servers, homelabs, and staging environments. Also, the nice thing about ngrok it is the fact that it offers subdomains and can work instantly. Also, subdomains are available so you don't have to purchase and maintain one if it's not a requirement.

Cloudflare, on the other hand, is more useful in production since it has more servers around the world and has more security configurations. But you need a domain name to use it (though easily offered by them).

Final Note

No matter whether you need to expose a server, use ssh or RDP, or if you have any other use case, those reverse proxy solutions can certainly be of benefit to you. Choose the one that best suits your needs and proceed with it.

Happy building!

Top comments (0)