> Markdown version of https://tuna.am/en/docs/tunnels/migrate/cloudflare-tunnel/. Documentation index: [llms.txt](https://tuna.am/en/llms.txt), full text in one file: [llms-full.txt](https://tuna.am/en/llms-full.txt). Any page is available as Markdown: append `.md` to its URL without the trailing slash.

# 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](https://tuna.am/en/docs/guides/install/install-cli.md) and sign in:

```shell
tuna login

```

| cloudflared                              | tuna                                |
| ---------------------------------------- | ----------------------------------- |
| `cloudflared tunnel login`               | `tuna login`                        |
| `cloudflared tunnel run --token <token>` | `TUNA_API_KEY=<key> tuna http 8080` |
| `TUNNEL_TOKEN`                           | `TUNA_API_KEY`                      |

On servers, in CI and in Docker, use an [API key](https://my.tuna.am/api_keys?lang=en) with "Run tunnels" enabled instead of signing in through a browser. See [Sessions and API keys](https://tuna.am/en/docs/guides/sessions-and-api-keys.md) for details.

## Quick tunnel

| cloudflared                                      | tuna             |
| ------------------------------------------------ | ---------------- |
| `cloudflared tunnel --url http://localhost:8080` | `tuna http 8080` |

As with a quick tunnel, the address is [dynamic](https://tuna.am/en/docs/tunnels/http.md#dynamic) and changes when you reconnect. To keep it stable, use your [free permanent subdomain](https://tuna.am/en/docs/tunnels/http.md#free-subdomain) — every account has one:

```shell
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](https://my.tuna.am/domains?lang=en) and create the CNAME record it shows. Step by step: [Connecting your own domain](https://tuna.am/en/docs/tunnels/guides/connect-self-domain.md).
2. Start the tunnel:

```shell
tuna http 80 --domain=app.example.com

```

| cloudflared                                        | tuna                                      |
| -------------------------------------------------- | ----------------------------------------- |
| `cloudflared tunnel create app`                    | not needed                                |
| `cloudflared tunnel route dns app app.example.com` | a CNAME record at your DNS provider, once |
| `cloudflared tunnel run app`                       | `tuna 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

```yaml
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

```yaml
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](https://tuna.am/en/docs/tunnels/guides/multi-tunnels.md) 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:

```shell
tuna tcp 5432

```

```shell
psql -h a.2na.am -p <port> -U postgres

```

| cloudflared                     | tuna                                                                                            |
| ------------------------------- | ----------------------------------------------------------------------------------------------- |
| `service: ssh://localhost:22`   | [`tuna ssh`](https://tuna.am/en/docs/tunnels/ssh.md) — a built-in SSH server — or `tuna tcp 22` |
| `service: tcp://localhost:5432` | [`tuna postgres 5432`](https://tuna.am/en/docs/tunnels/postgres.md) or `tuna tcp 5432`          |
| `service: unix:/path/to.sock`   | [`tuna http unix:///path/to.sock`](https://tuna.am/en/docs/tunnels/http.md#unix-socket)         |

For a permanent address, use a [reserved port](https://tuna.am/en/docs/tunnels/ports.md), for example `tuna tcp 5432 --port=db`. TCP tunnels require a [subscription](https://tuna.am/#pricing).

## 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](https://tuna.am/en/docs/apps.md):

| Cloudflare                                | tuna                                                                                                            |
| ----------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| Access: SSO or email sign-in              | [Apps](https://tuna.am/en/docs/apps.md)                                                                         |
| `--allowed-mail` on a quick tunnel        | [Apps](https://tuna.am/en/docs/apps.md) or [`--basic-auth`](https://tuna.am/en/docs/tunnels/http.md#basic-auth) |
| IP access rules                           | [`--cidr-allow`, `--cidr-deny`](https://tuna.am/en/docs/tunnels/http.md#cidr)                                   |
| Workers: headers, redirects, URL rewrites | [Traffic Policies](https://tuna.am/en/docs/traffic-policy.md)                                                   |

## 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:

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

```

The Docker image is `yuccastream/tuna`:

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

```

See [Running in the background](https://tuna.am/en/docs/tunnels/guides/service.md) and [Containers](https://tuna.am/en/docs/guides/install/install-containers.md) for details.

## Next steps

* [HTTP tunnel](https://tuna.am/en/docs/tunnels/http.md): all flags and examples.
* [Request Inspector](https://tuna.am/en/docs/tunnels/inspect.md): tunnel requests at `http://127.0.0.1:4040`, with replay.
* [Pricing](https://tuna.am/#pricing): what's free and what needs a subscription.
