Cloudflare tutor

A morning desk for Kotha · Gold Coast

· Australia/Brisbane · Lesson

Cloudflare Tunnel: publish a service from your VPS without opening a port

Cloudflare Tunnel (cloudflared)

What it is

A Cloudflare Tunnel connects a service running on your own machine, such as an app on a Hostinger VPS, to Cloudflare by an outbound connection. A small program called cloudflared runs next to the app and dials out to Cloudflare. Visitors then reach a hostname such as notes.kosan.xyz at Cloudflare, and Cloudflare passes the request down the tunnel to the app. Because the connection goes outward, you do not need to open an inbound port or expose the server's IP address.

There are three pieces. The tunnel itself is a named connection with an ID. The connector is the cloudflared process, which can run as a service or a Docker container. A public hostname (shown in the dashboard under Networks, then Tunnels; the wording may differ slightly) is a rule that says which hostname goes to which local address, for example notes.kosan.xyz to http://localhost:3000. Creating a public hostname also adds a proxied CNAME record in DNS that points at the tunnel.

A tunnel is different from a Worker. A Worker runs your code on Cloudflare's network. A tunnel leaves your code where it is and only gives it a safe way in. Many setups use both: the tunnel for the app that must stay on the VPS, and Workers for lightweight pages and APIs.

Why it matters

Your VPS apps are currently reachable because their ports are open to the internet. A tunnel lets you close those ports and let only Cloudflare reach the app, which reduces what attackers can scan and hit directly. Since the hostname is proxied, you also get the usual Cloudflare protections in front of it.

It also helps with things that are awkward to expose, such as a dashboard on your home network or a service behind a firewall, and it pairs well with Cloudflare Access (Zero Trust) later in this course, so a private tool asks for a login before anyone sees it.

The caution: a tunnel makes whatever it points at reachable on the public internet unless you add protection. Never publish anything holding patient information without a login in front of it, and remember that if the connector stops, the hostname shows an error until it is running again.

On your account

From your own setup: your OpenClaw and Coolify stack runs on the Hostinger VPS srv1900896, and apps there such as notes.kosan.xyz are reached through DNS records on the kosan.xyz zone. A tunnel is an alternative route for the same apps, with cloudflared on the VPS and each hostname mapped to its local port, so the VPS firewall could eventually block direct web traffic.

The tutor you are reading now does not use a tunnel. cloudflare.kosan.xyz is served directly by the cloudflare-tutor Worker, and its wrangler.toml has routes only.

Nothing in this lesson installs cloudflared, creates a tunnel, or changes DNS, the VPS, or any Worker.

Do this yourself

These stay in the dashboard, on your side. This site does not change DNS, routes, or other Workers.

  1. In the Cloudflare dashboard, open the Tunnels page under Networks (menu wording may differ slightly) and read only: note whether any tunnels already exist and whether their status is Healthy or Down. Then, on paper, list three apps on your VPS that you would publish through a tunnel and three you would keep private, and for each write the hostname and local port it would use (for example notes.kosan.xyz to localhost:3000). Do not create a tunnel, install cloudflared, or change DNS or the VPS firewall.