Skip to content

Instantly share code, notes, and snippets.

@abdullah-ctl
Last active May 4, 2025 10:02
Show Gist options
  • Save abdullah-ctl/6b35aedb636b80592defda0a5862aa13 to your computer and use it in GitHub Desktop.
Save abdullah-ctl/6b35aedb636b80592defda0a5862aa13 to your computer and use it in GitHub Desktop.
Perfect free alternative of Ngrok tunneling

Cloudflare Tunneling

The Pros:

- No bandwidth limit 
- Easy to start 
- No account / access token requires

The Cons:

- Domain will be changes when process exited

Is have any solution of the Cons? Yes. We can fix the process exited issue And also the domain changed issue --requires to buy a domain

Lets start ...

Installation

wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb

sudo dpkg -i cloudflared-linux-amd64.deb 

sudo apt-get install -f

Is installed ?

cloudflared --version

Start tunneling :

cloudflared tunnel --url localhost:8008

NB: A serious note if your port is localhost:80 then please only use ``cloudflared tunnel --url localhost`

The Problem

Now if I terminate the process from terminal then the domain will change again πŸ˜•

The solution

We will use a linux tool called nohup that stands for no hangup and it will solves us

nohup cloudflared tunnel --url localhost:8008 &

NB: The & at the end of the command makes the process run in the background.

The nohup created a file called nohup.out in your current directory where you get the cloudflared tunneling logs.

On nohup.out file you will find the tunneling domain also.

Now how we stop the cloudflared process ?

#all running processes and filters for cloudflared

ps aux | grep cloudflared

# only PID(s)
pgrep cloudflared

# now kill the pid
kill PID

# for force kill 
kill -9 PID

Now what we have limitation ?

  • If you stop our computer or restart then the domain will change

Is there any solution for this?

Yes we have but we need a custom domain and that need to config with cloudflare. But I think this our solution is enough.

If you want to know more about the domain config related things, then go here

@mhrubel
Copy link

mhrubel commented Apr 30, 2025

🌐 Cloudflared Tunnel Script

Easily expose your local server to the internet using Cloudflare Tunnel.
This script supports Linux, macOS, and Windows (via Git Bash).


πŸš€ Quick Start

  1. Clone or download the script:

    curl -O https://raw.githubusercontent.com/RactStudio/plugin-frame/master/pf/cf-tunnel.sh
  2. Run the script:

    ./cf-tunnel.sh

πŸ’‘ Notes

  • Windows users:
    Use Git Bash to run the script.
    Keep the terminal open as long as you want the tunnel/domain to remain active.

πŸ“Ž Script Link:
cf-tunnel.sh on GitHub

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment