Cloudflare Tunnels
Publish wtree Cloud apps through Cloudflare Tunnels without opening ports 80 and 443 on your server.
A Cloudflare Tunnel opens an outbound-only connection from your server to Cloudflare, which routes public traffic to your apps. It works behind NAT and restrictive firewalls, and wildcard routes let one tunnel serve many subdomains.
Before you start
- A domain managed by Cloudflare (the free plan works).
- A running wtree Cloud instance.
- Access to the Cloudflare dashboard.
Cloudflare terminates SSL at its edge. In wtree Cloud, leave HTTPS and certificate providers off on domains served through the tunnel and use HTTP internally.
Create the tunnel
Create it in Cloudflare
In the Cloudflare dashboard, open Zero Trust → Networks → Connectors (Access in older dashboards) and click Create a tunnel. Choose Cloudflared, name it (for example wtree-cloud-tunnel) and copy the Tunnel Token. The token grants routing to your server, so keep it secret.
Set the SSL mode
Under SSL/TLS, set the encryption mode to Full or Full (Strict). Flexible can cause redirect loops with Traefik.
Deploy cloudflared
- Create an application with the Docker source and the image
cloudflare/cloudflared. - In Settings › Environment variables add
TUNNEL_TOKEN="<your token>". - In Settings › Resources, in the Run command card, click Add argument twice to add
tunnelthenrun, and save. - Deploy.
The container shows as healthy in the logs.
Route traffic
You can send tunnel traffic through Traefik or straight to a container.
| Through Traefik | Direct to container | |
|---|---|---|
| Flow | Cloudflare, tunnel, Traefik, app | Cloudflare, tunnel, app |
| Domains in wtree Cloud apply (redirects, path rewrites) | Yes | No |
| Hostnames in Cloudflare | One wildcard covers all apps | One per container |
| Use it for | Most setups | A single dedicated service |
Through Traefik
In your tunnel, open Configure → Published application routes and click Add a published application route:
| Field | Value |
|---|---|
| Subdomain | For example app |
| Domain | Your domain |
| Service type | HTTP |
| URL | w3panel-traefik:80 |
Traefik routes the request by the domain set on the app in wtree Cloud. To test, create an application from the nginx Docker image, deploy it, then add a domain in Settings › Domains that matches the Cloudflare route. Set the port to 80, and leave the HTTPS toggle and certificate provider off.
Direct to a container
Set the route's service to HTTP with the URL appName:port, for example my-app:8080. The app name is shown under the service name, usually project-serviceName-hash. Traefik is bypassed, so wtree Cloud domain settings don't apply.
Wildcard for many apps
Use one route for every subdomain.
In Connectors, copy the Tunnel ID.
In your domain's DNS Records, add a record: type CNAME, name *, content <tunnel-id>.cfargotunnel.com.
In the tunnel's Published application routes, add a route with subdomain *, your domain, HTTP, and w3panel-traefik:80.
Traefik sends app1.example.com, app2.example.com and the rest to the matching apps.
Protect the panel with Cloudflare Access
With Cloudflare Access in front of the panel, the login request (POST /api/auth/sign-in/email) can hang with valid credentials, while invalid credentials return 401 at once. The auth library checks the Origin header of each request, and requests through Access may not match a trusted origin, so they are dropped silently.
Set all three:
-
Keep a stable
BETTER_AUTH_SECRET. If it is missing or changes between restarts, sessions are invalidated.openssl rand -hex 32 -
List every origin that reaches the panel in
BETTER_AUTH_TRUSTED_ORIGINS. Include the public domain, and any internal IP or Tailscale address you use.BETTER_AUTH_TRUSTED_ORIGINS=http://localhost:3000,http://<internal-ip>:3000,https://cloud.example.com -
In Servers › This server › Settings, set Domain to your public domain and enable HTTPS. This adds the domain as a trusted origin.
Redeploy the wtree Cloud service so the variables take effect.
