Let's setup a Cloudflare Tunnel using Docker Compose.
Our goal will be to proxy an entire app deployed in an internal network to our own subdomain publicly.
- Login to Zero Trust
- Go to Networks > Tunnels > Add a tunnel
- Choose Cloudflared for the connector type and select Next
- Enter a name for your tunnel
- Save tunnel!
Grab the given token from the page and write the following
docker-compose.yml
file.
version: 2 # update according to your needs!
services:
cloudflared:
image: cloudflare/cloudflared:latest
restart: always
command: >
tunnel --no-autoupdate run --token ${CLOUDFLARED_TUNNEL_TOKEN}
You'll also need a .env
file with the following content.
CLOUDFLARED_TUNNEL_TOKEN="your-token"
Deploy this compose configuration!
- Choose a subdomain (optional), a domain and a path (optional) for the hostname of the thunnel.
- Select what type of service you want to tunnel
If you're proxying an HTTPS service, you can add more settings such as HTTP > HTTP Host Header
which sets the HTTP Host
header on requests sent to the local service.