zrok Tutorial: The Ngrok Alternative to Publicly Share Localhost Fast and Securely

Network tutorial - IT technology blog
Network tutorial - IT technology blog

The Nightmare of Demoing Projects from a Local Machine

Just finished a cool feature and want to send a demo link to a client right away? Or need to receive a Stripe Webhook on your home Raspberry Pi server? Previously, Ngrok was the go-to choice. However, Ngrok’s free version is now quite restrictive: 1GB bandwidth limit, constantly changing URLs, and frequent browser blocks with ‘Deceptive site’ warnings.

After struggling with various tunnels, I found zrok. This is an open-source tool built on the OpenZiti platform. It doesn’t just help you ‘punch through’ NAT or firewalls in 30 seconds; it’s also incredibly generous with features. The standout feature is that zrok lets you share HTTP, TCP, and even turn a folder into a network drive with a single command.

I once spent an entire morning just configuring port forwarding on an old router at a client’s office. With zrok, those barriers disappear. You don’t need a static IP or router admin rights; as long as you have internet, you’re good to go.

Why zrok is Worth Every Penny (Even Though It’s Free)

Technically, zrok creates a secure tunnel from your machine to their gateway. When a user accesses the URL, the request is securely routed directly back to your localhost.

Reasons why I switched from Ngrok to zrok:

  • Bypass NAT/Firewall: Works perfectly even if your machine is behind three layers of networking.
  • Private Mode: Only authorized users can access it, making it extremely secure for SSH.
  • Self-hosted: If you don’t trust zrok’s public servers, you can host your own to manage 100% of your data.
  • No Bandwidth Throttling: Currently, their free SaaS version runs very smoothly for typical demo tasks.

Quick Deployment on Linux

Here are the steps I performed on Ubuntu 22.04; other distributions follow a similar process.

1. Get an Identity Token

Visit zrok.io to register an account. After confirming your email, log in to the dashboard. Here, you will see the zrok invite command with a long token string. Save this code to enable your environment in the next step.

2. Install zrok

Instead of manually downloading compressed files, use the official script to automate everything:

curl -sSLf https://get.zrok.io | sudo bash

Once installed, check with the zrok version command. If the version appears (e.g., v0.4.x), you’re halfway there.

3. Enable the Environment

Now, ‘marry’ your computer to the zrok system using the token obtained in step 1:

zrok enable <your_token_here>

This command creates a unique secure identity for your machine. You only need to do this once.

3 Common Real-World Use Cases

Scenario 1: Quickly Publicize a Web App (Port 8080)

Suppose you’re running a Node.js app on port 8080. To get a link for a partner, type:

zrok share public http://localhost:8080

Immediately, a URL ending in .share.zrok.io will appear. All requests to this URL will be forwarded directly to your machine. Very convenient!

Scenario 2: Keep a Persistent URL for Webhooks

Are you integrating Stripe Webhooks and don’t want to change the URL in the Stripe dashboard every time you restart zrok? Use the reserve feature.

First, reserve a specific name:

zrok reserve public http://localhost:8080 --unique-name my-webhook-api

From now on, whenever you work, just run:

zrok share reserved my-webhook-api

Your URL will always be my-webhook-api.share.zrok.io. Note: This name must be unique across the entire zrok system.

Scenario 3: Share Log Files or Document Folders

This is the feature I use most when I need to send log files several hundred MBs in size to colleagues. Instead of wasting time uploading to Google Drive, I share the folder directly:

zrok share public ./logs_folder --backend-mode web

The recipient will see a simple web interface to browse and download files directly from your machine at maximum speed.

Advanced Security with Private Share

Want to SSH into your home machine from a cafe but afraid of hackers brute-forcing your password? Use private mode. This is where the Zero Trust power of OpenZiti shines.

On the home machine (Server):

zrok share private localhost:22 --backend-mode tcp

You will receive an access code (e.g., abc123xyz).

On the cafe machine (Client):

zrok access private abc123xyz

This command will open a port on the client machine itself (usually 9191). Now, just SSH into your own localhost:

ssh user@localhost -p 9191

At this point, your SSH service is completely hidden from the internet. No one can see or scan your port 22.

Hard-Won Tips and Lessons

While zrok is powerful, data still passes through their intermediary servers. If you find file download speeds slow, it’s due to the geographical distance to the gateway. For projects requiring ultra-low latency, consider setting up a self-hosted zrok on a local VPS.

Additionally, if you’re publicizing a URL to many people, add a basic security layer to prevent bot scanning:

zrok share public http://localhost:8080 --basic-auth admin:password123

In Summary…

zrok is a compact yet extremely versatile tool for Developers and DevOps professionals. It perfectly solves the problem of sharing services without sacrificing security. If you’re tired of Ngrok’s limitations, install zrok today. It only takes 2 minutes to take full control of your connection.

Share: