Expose Self-Hosted Apps Behind CGNAT with Tunnels
Zusammenfassung
Pixel shares a practical look at using Cloudflare Tunnel to expose self-hosted apps behind CGNAT without opening inbound ports. The announcement explains Levelrail’s experimental cloudflared integration, what its docs and tests verify, and why real-world traffic remains untested; it also notes that certificates still require DNS-01.
DEV Community
My ISP would not give me a public IP, so I stopped asking for one
My ISP would not give me a public IP, so I stopped asking for one I once spent an evening forwarding port 443 on a home router, only to find the router's "WAN address" was a private range. My provider shared one public IPv4 address between many customers. No port forward on my side could ever work, because the traffic never reached my router. That setup is called carrier-grade NAT, or CGNAT, and it is common on home and mobile connections. The usual answer is a tunnel: a small program on your server dials out to a provider, and visitors come in through the provider. Levelrail, the self-hosted deploy platform I work on, can run a Cloudflare Tunnel connector for you. This post covers what I could verify and what I could not, because the honest answer on that second part matters for your decision. TL;DR Question Answer Verified how Need an open inbound port? No, the connector dials out Cloudflare docs Does Levelrail run the connector? Yes, one cloudflared container I ran it locally Did a real tunnel carry traffic? Not tested by me No Cloudflare account used Is the feature finished? The docs call it experimental Levelrail docs Do I still need a certificate? Yes, use DNS-01 Levelrail docs What I did not test, up front I did not create a Cloudflare tunnel, did not route a hostname through one and did not load a page over one. A real tunnel needs a token from a Cloudflare account, and I did not use one. The Levelrail docs say the same about themselves: the feature is built and covered by reconciler and API unit tests, but has not been proven on a real host with a real Cloudflare account. Everything about live traffic below comes from the docs, not from me. How a tunnel gets around CGNAT Cloudflare describes its tunnel as an outbound-only connection model, and says it connects resources without a publicly routable IP address. Its guidance for firewalls is to allow only those outbound connections and block inbound traffic. That is exactly what CGNAT permits: your server can reach out, and nobody can reach in. Public hostnames are routed on Cloudflare's side. In the Zero Trust dashboard you add a published application, pick a subdomain and domain, and set a service URL that the connector can reach. The domain must already be on Cloudflare, and the application is publicly reachable until you add an Access policy. What Levelrail adds Levelrail starts one container named -cloudflared from cloudflare/cloudflared, running tunnel --no-autoupdate run, and passes your tunnel token as the TUNNEL_TOKEN environment variable. The token is stored encrypted and is never returned by the API or CLI (docs/cloudflare-tunnel.md). Levelrail does not configure Cloudflare for you. The hostname-to-service mapping is yours to set in their dashboard. The commands, once you have a real token: levelrail-cli cloudflare-tunnel set --cf-tunnel-token TOKEN
levelrail-cli cloudflare-tunnel get
The feature is off by default and has to be switched on first. I did it with the APP_EXPERIMENTAL=cloudflare-tunnel seed on a local dev instance, and the docs also describe a dashboard switch in Settings. What I ran, with a fake token To see the reconciler work without an account, I gave it a deliberately invalid token on a throwaway local control plane (a build of the v1.0.1 release branch, on a Mac with Docker). The container appeared, pinned to cloudflare/cloudflared:2026.10.7, with the command tunnel --no-autoupdate run, no host port bindings, and restart policy no. $ levelrail-cli cloudflare-tunnel get
enabled: true
has_token: true
status: connected
$ docker logs Levelrail-cloudflared
Provided Tunnel token is not valid.
Two things stand out. First, no inbound port was published, which matches the pitch. Second, the st...

Powered by Readybot.io