Zero Trust Tunnel
Zero Trust Tunnel
Here’s a clean, complete documentation for setting up a Cloudflare Tunnel using Docker Compose and exposing a local service like Portainer on a public subdomain (protainer.xrito.xyz
).
🌐 Cloudflare Tunnel Setup (Docker Compose)
This guide explains how to expose a local web service (e.g., Portainer) to the internet securely using Cloudflare Tunnel and Docker Compose.
🛠️ Prerequisites
- A Cloudflare account
- Your domain (e.g.,
xrito.xyz
) added to Cloudflare - Docker + Docker Compose installed on your machine
- A web service running locally (e.g., Portainer on
http://192.168.0.100:9000
)
🔧 Step 1: Create Tunnel in Cloudflare Zero Trust
- Go to Cloudflare Zero Trust dashboard.
Navigate to:
1
Access > Tunnels > Create a Tunnel
- Name your tunnel (e.g.,
portainer-tunnel
) - Choose Docker as the installation method.
📦 Step 2: Docker Compose Setup
- Copy the token provided by Cloudflare.
- Create a
docker-compose.yml
file:
1
2
3
4
5
6
7
8
version: '3.8'
services:
cloudflare-tunnel:
image: cloudflare/cloudflared:latest
container_name: cloudflare-tunnel
restart: unless-stopped
command: tunnel --no-autoupdate run --token <your-token>
🔁 Replace
<your-token>
with the actual token from Cloudflare.
- Start the tunnel:
1
docker compose up -d
🌍 Step 3: Public Hostname Configuration
Go back to the Tunnel configuration page in Cloudflare.
Add a Public Hostname:
- Subdomain:
protainer
- Domain:
xrito.xyz
- Type:
HTTP
- URL:
http://192.168.0.100:9000
(replace with your local IP and service port)
- Subdomain:
Click Save hostname and complete the setup.
✅ Result
You can now access your local service from anywhere using:
1
https://protainer.xrito.xyz
Cloudflare will securely route the request to your local Portainer server through the tunnel.
📄 Notes
- Make sure your local service (e.g., Portainer) is reachable on the specified IP and port.
- If using a firewall or NAT, ensure local access is possible.
- No need to open ports on your router — Cloudflare Tunnel takes care of the secure connection.
Let me know if you want this as a downloadable .md
or .pdf
file.
This post is licensed under CC BY 4.0 by the author.