Using Cloudflare Tunnels to access your SPIN Runtime
Cloudflare Tunnels is a service that allows you to make your SPIN runtime accessible from the internet while still allowing it to run behind a firewall.Quick Tunnels
For trial and testing purposes, you can use quick tunnels, which allow you to create a tunnel without signing up with Cloudflare.Docker Compose Example
<SPIN_TOKEN>
with the token you receive in the SPIN UI when creating a new runtime.
Then run the containers by running:
Getting the Runtime URL
To obtain the runtime URL, view the logs of the cloudflare-tunnel container:https://toronto-foul-enlargement-gothic.trycloudflare.com
in the example above) and paste it in the SPIN UI runtime URL field.
Quick Tunnel Limitations
- The URL will change on every restart (this requires you to update the runtime config in the SPIN UI)
- No uptime guarantees by Cloudflare
- Best suited for testing before setting up a permanent tunnel
Permanent Tunnels
For production use, you should set up a permanent tunnel. Prerequisites:- A Cloudflare account
- A DNS domain on Cloudflare
- Configure tunnel in the Cloudflare dashboard
- Run spin-runtime with cloudflared sidecar in docker
Configure Cloudflare Tunnel
First, head over to your Cloudflare dashboard, then navigate to Zero Trust -> Networks -> Tunnels.

--token
flag).
We’ll use this token in the next step when we configure the SPIN runtime in docker compose.

A
: A hostname for the tunnelB
: Select a DNS domain you own on CloudflareC
: The service URL:http://spin-runtime:8888/

https://<hostname>.<domain>
.
In the example above, the tunnel will be reachable at https://mytunnel.spintun.net
.
This is the value we’ll provide when configuring the runtime in the SPIN UI.
Run SPIN Runtime with Cloudflare Tunnel
<SPIN_TOKEN>
with the token you receive in the SPIN UI when creating a new runtime and replace <CLOUDFLARE_TUNNEL_TOKEN>
with the token you copied in the previous step.
Then run the containers by running: