Skip to main content

Migrating from Cloudflare Tunnel

With Cloudflare Tunnel, you first create a tunnel, look up its UUID, write a config.yml with ingress rules and add a DNS record with a separate command. tuna has no UUIDs and no credentials files, and our subdomains don't need DNS records. A tunnel is a single command with a port and an address.

Installing and signing in​

Install tuna by following the instructions and sign in:

tuna login
cloudflaredtuna
cloudflared tunnel logintuna login
cloudflared tunnel run --token <token>TUNA_API_KEY=<key> tuna http 8080
TUNNEL_TOKENTUNA_API_KEY

On servers, in CI and in Docker, use an API key with "Run tunnels" enabled instead of signing in through a browser. See Sessions and API keys for details.

Quick tunnel​

cloudflaredtuna
cloudflared tunnel --url http://localhost:8080tuna http 8080

As with a quick tunnel, the address is dynamic and changes when you reconnect. To keep it stable, use your free permanent subdomain β€” every account has one:

tuna http 8080 --subdomain=<your-subdomain>

Server-sent events and WebSocket work with no extra setup.

Tunnel on your own domain​

Cloudflare needs the whole domain added to Cloudflare. tuna needs only a CNAME record at your DNS provider:

  1. Add the domain in the dashboard and create the CNAME record it shows. Step by step: Connecting your own domain.
  2. Start the tunnel:
tuna http 80 --domain=app.example.com
cloudflaredtuna
cloudflared tunnel create appnot needed
cloudflared tunnel route dns app app.example.coma CNAME record at your DNS provider, once
cloudflared tunnel run apptuna http 80 --domain=app.example.com

Several services: config.yml​

Each ingress rule pairs an address with a local service. In tuna, that's a tunnel in a .tuna.yml file in the project directory. You don't need the http_status:404 catch-all rule at the end.

Before, in ~/.cloudflared/config.yml:

config.yml
tunnel: <UUID>
credentials-file: /root/.cloudflared/<UUID>.json
ingress:
- hostname: app.example.com
service: http://localhost:8000
- hostname: api.example.com
service: http://localhost:9000
- service: http_status:404

After, in .tuna.yml:

.tuna.yml
tunnels:
app:
commandLine: tuna http 8000 --domain=app.example.com
api:
commandLine: tuna http 9000 --domain=api.example.com

Start them all with tuna start --all, or one with tuna start app. See Multiple Tunnel Startup for details.

SSH, databases and other TCP services​

With Cloudflare Tunnel, whoever connects to an ssh:// or tcp:// service usually has to install cloudflared or a Cloudflare client. In tuna, a TCP tunnel gets a public address with a port, and any regular client can connect:

tuna tcp 5432
psql -h a.2na.am -p <port> -U postgres
cloudflaredtuna
service: ssh://localhost:22tuna ssh β€” a built-in SSH server β€” or tuna tcp 22
service: tcp://localhost:5432tuna postgres 5432 or tuna tcp 5432
service: unix:/path/to.socktuna http unix:///path/to.sock

For a permanent address, use a reserved port, for example tuna tcp 5432 --port=db. TCP tunnels require a subscription.

Access control​

Cloudflare restricts access with a separate product, Cloudflare Access, and modifies requests with Workers. In tuna, basic protection is set with tunnel flags, and SSO sign-in lives in Apps:

Cloudflaretuna
Access: SSO or email sign-inApps
--allowed-mail on a quick tunnelApps or --basic-auth
IP access rules--cidr-allow, --cidr-deny
Workers: headers, redirects, URL rewritesTraffic Policies

Running in the background and Docker​

cloudflared service install sets up a service that keeps the tunnel running after a reboot. In tuna, a service runs one tunnel command:

tuna service install --name=app -- tuna http 8000 --domain=app.example.com

The Docker image is yuccastream/tuna:

docker run -d --network host -e TUNA_API_KEY=<your_key> yuccastream/tuna http 8000

See Running in the background and Containers for details.

Next steps​