Cloudflare Tunnel
Expose App and Box services through a Cloudflare Tunnel without opening ports on the server.
A Cloudflare Tunnel sends traffic from Cloudflare to your server over an outgoing connection, so your services can be reached on your domains without opening ports 80 and 443 to the internet or publishing the server's IP address in DNS.
Easypanel runs the cloudflared connector as a service and manages the
tunnel's routes and DNS records for you. Each route is a tunnel rule that
points a hostname on one of your Cloudflare domains to a port of an App or Box
service.
Cloudflare Tunnel support is experimental. Test it on a non-critical service before moving production traffic to it.
Requirements
- A Cloudflare account with at least one domain (zone) on Cloudflare DNS.
- An API token with these permissions:
- Account → Account Settings → Read
- Account → Cloudflare Tunnel → Edit
- Zone → Zone → Read
- Zone → DNS → Edit
To create the token, go to dash.cloudflare.com/profile/api-tokens, select Create Token, then Create Custom Token, and add the permissions above.
Create a tunnel
- Open the Cloudflare One dashboard and select your account.
- Go to Networks → Tunnels and select Create a tunnel.
- Select Cloudflared as the connector type.
- Name the tunnel and select Save tunnel. You do not need to install the connector yourself; Easypanel runs it.
Connect Easypanel
- Open Settings → Server → Cloudflare Tunnel.
- Paste the token into API Token.
- Select your account in Accounts, or enter the Account ID.
- Select the tunnel in Tunnels, or enter the Tunnel ID.
- Optionally set the Region. See Region.
- Select Save, then select Start Tunnel.
Stop Tunnel removes the connector service. The saved configuration and tunnel rules are kept, so Start Tunnel brings them back.
Region
By default, cloudflared connects to Cloudflare's global network. Set
Region to connect only to a specific region, for example us for data
centers in the United States. Leave it empty to use the global region. See the
Cloudflare documentation
for supported values.
Changing the region of a running tunnel restarts the connector, which briefly interrupts traffic through the tunnel.
Add a tunnel rule
Tunnel rules are managed from the Domains tab of an App or Box service. The Cloudflare Tunnel Rules panel appears there while the tunnel is running.
- Open the service and select the Domains tab.
- In Cloudflare Tunnel Rules, select Add Tunnel Rule.
- Select the Domain and enter an optional Subdomain. Leave the subdomain empty to use the domain itself.
- Optionally enter a Path to route only matching requests.
- Select the Internal Protocol and enter the Internal Port the application listens on inside the container.
- Select Create.
Easypanel creates a proxied CNAME record for the hostname that points to the
tunnel, and adds the route to the tunnel configuration. Editing a rule updates
both, and removing a rule deletes the DNS record and the route. Deleting a
service removes its tunnel rules.
Routes that you add to the tunnel outside Easypanel, for example in the Cloudflare dashboard, are kept when Easypanel updates the tunnel configuration.
Troubleshooting
- The Cloudflare Tunnel Rules panel is missing: the tunnel is not running. Select Start Tunnel in Settings → Server → Cloudflare Tunnel.
- No accounts, tunnels, or domains are listed: check that the API token has all the permissions listed in Requirements.
- Creating a rule fails: check that no DNS record already exists for that hostname in Cloudflare. Remove it, or choose another subdomain.
- The hostname returns a 404 or a 502 error: check that the service is running and that the internal port and protocol match what the application listens on.