Free Tool

Free Cloudflare Tunnel Config Generator

A Cloudflare Tunnel puts a local app, home server or homelab service on your own domain without opening any ports: cloudflared connects out to Cloudflare and forwards each hostname to a local address. This generator writes the config.yml, the setup commands in order and a keep-alive service for your system.

Everything runs in your browser. Nothing you type is sent anywhere.

1. Describe your tunnel

Where cloudflared runs
Services (public hostname to local address)

Type just app and it becomes app.example.com. A final catch-all rule is added for you.

2. Checks

No errors. Add the Tunnel ID after step 3 to finish the config.

  • Tip:After you run tunnel create, paste the Tunnel ID to replace <TUNNEL-ID>.
  • Tip:ssh.example.com: SSH clients connect through cloudflared. Add the ProxyCommand block below to ~/.ssh/config on each laptop.

3. Your setup, in order

  1. 1Install cloudflared

    Terminal

    brew install cloudflared
  2. 2Log in to Cloudflare

    Opens a browser (or prints a URL on a headless server). Pick example.com. This saves cert.pem in ~/.cloudflared.

    Terminal

    cloudflared tunnel login
  3. 3Create the tunnel

    Prints the Tunnel ID and writes <ID>.json in ~/.cloudflared. Paste the ID into the Tunnel ID field above to fill it in everywhere.

    Terminal

    cloudflared tunnel create homelab
  4. 4Point each hostname at the tunnel

    Creates a proxied CNAME to <ID>.cfargotunnel.com for every hostname.

    Terminal

    cloudflared tunnel route dns homelab app.example.com
    cloudflared tunnel route dns homelab ssh.example.com
  5. 5Save config.yml

    Paste the config.yml below.

    Terminal

    nano /Users/you/.cloudflared/config.yml
  6. 6Check the rules, then run it

    Terminal

    cloudflared tunnel ingress validate
    cloudflared tunnel ingress rule https://app.example.com
    cloudflared tunnel run homelab

/Users/you/.cloudflared/config.yml

# /Users/you/.cloudflared/config.yml
# Generated by codecard.dev/tools/cloudflare-tunnel-config-generator
tunnel: <TUNNEL-ID>
credentials-file: /Users/you/.cloudflared/<TUNNEL-ID>.json
ingress:
  - hostname: app.example.com
    service: http://localhost:3000
  - hostname: ssh.example.com
    service: ssh://localhost:22
  - service: http_status:404

Start at login with launchd

Intel Macs: change /opt/homebrew/bin/cloudflared to /usr/local/bin/cloudflared (check with: which cloudflared).

com.cloudflare.tunnel.homelab.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>com.cloudflare.tunnel.homelab</string>
  <key>ProgramArguments</key>
  <array>
    <string>/opt/homebrew/bin/cloudflared</string>
    <string>tunnel</string>
    <string>--config</string>
    <string>/Users/you/.cloudflared/config.yml</string>
    <string>run</string>
    <string>homelab</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
  <key>KeepAlive</key>
  <true/>
  <key>StandardErrorPath</key>
  <string>/Users/you/Library/Logs/com.cloudflare.tunnel.homelab.log</string>
</dict>
</plist>

Terminal

nano ~/Library/LaunchAgents/com.cloudflare.tunnel.homelab.plist   # paste the file
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.cloudflare.tunnel.homelab.plist
launchctl print gui/$(id -u)/com.cloudflare.tunnel.homelab | grep state

SSH from your laptop

Install cloudflared on the laptop too, add this to ~/.ssh/config, then run ssh you@ssh.example.com.

~/.ssh/config

Host ssh.example.com
  ProxyCommand cloudflared access ssh --hostname %h

Check an existing config.yml

Paste your config to catch a missing catch-all, a wrong credentials-file, a missing scheme and other mistakes. It is checked in your browser.

Cloudflare Tunnel, Tailscale or ngrok?

Best fit

Cloudflare Tunnel

Free, works on your own domain with HTTPS, and needs no open ports. Your domain's DNS must be on Cloudflare.

Built a homelab? Show the hours behind it

Code Card turns your Claude Code, Codex, and OpenClaw sessions into a public profile with activity graphs, token breakdowns, badges, and shareable developer cards. Start with npx code-card.

Get Code Card

How to set up a Cloudflare Tunnel

  1. 1

    Describe the tunnel

    Enter a tunnel name, your Cloudflare domain and each hostname with the local address it should reach.

  2. 2

    Pick where it runs

    Choose macOS, Linux, Raspberry Pi, Windows or Docker to get matching install commands and file paths.

  3. 3

    Run the commands

    Log in, create the tunnel, route DNS, paste the Tunnel ID back in and save config.yml.

  4. 4

    Keep it running

    Install the launchd, systemd, Windows service or Docker Compose file so the tunnel restarts on boot.

Cloudflare Tunnel vs Tailscale vs ngrok

All three reach a local service without port forwarding. They differ in who can reach it and on what address.

Cloudflare TunnelTailscalengrok
Best forSites and apps on your own domainPrivate access to your own devicesWebhook testing and quick demos
Public or privatePublic; private with Cloudflare AccessPrivate; public with FunnelPublic
Your own domainYes, required for named tunnelsNo, ts.net names with FunnelOn paid plans
Free planYes, no bandwidth feeYes, Personal planLimited, with a browser warning page
Visitors need an appNo for websites; cloudflared for SSH and TCPYes, unless you use FunnelNo

FAQ

Cloudflare Tunnel questions

Is Cloudflare Tunnel free?

Yes. cloudflared and Cloudflare Tunnel are free on every Cloudflare plan, including Free, with no bandwidth fee. You need a Cloudflare account and a domain that uses Cloudflare DNS for a named tunnel on your own hostname.

Do I need a domain for Cloudflare Tunnel?

For a permanent tunnel on your own hostname, yes: the domain's nameservers must point to Cloudflare. For a quick test, cloudflared tunnel --url http://localhost:3000 gives you a random trycloudflare.com address with no account or domain.

Cloudflare Tunnel vs Tailscale: which should I use?

Use Cloudflare Tunnel to publish a website or app to the internet on your domain. Use Tailscale to reach your own devices privately over WireGuard. Tailscale Funnel can publish a service too, but only on a ts.net name and on ports 443, 8443 or 10000.

Is Cloudflare Tunnel safe?

cloudflared only makes outbound connections, so you open no ports and your home IP stays hidden. Anything you route is public, though, so put a Cloudflare Access login in front of admin panels. TLS ends at Cloudflare's edge, which means Cloudflare can see the traffic.

Why does config.yml need http_status:404 at the end?

cloudflared checks ingress rules top to bottom and requires the last rule to match every request. A final - service: http_status:404 answers unknown hostnames with a 404; without it, cloudflared refuses to start.

Why does my tunnel show 502 Bad Gateway?

cloudflared reached Cloudflare but not your app. The usual causes are a wrong port, http:// for an app that only speaks HTTPS, a self-signed certificate without noTLSVerify, or localhost inside a Docker container, where it means the container itself.

Should I use a config.yml or a dashboard token?

Both work. A dashboard-managed tunnel stores its routes in the Cloudflare Zero Trust dashboard and runs with cloudflared tunnel run --token. A locally managed tunnel, which this tool generates, keeps routes in config.yml so you can version them in git.