Remotely-managed tunnel
If you created a Cloudflare Tunnel from the dashboard, the tunnel runs as a service on your OS.
You can modify the Cloudflare Tunnel service with one or more general-purpose tunnel parameters.
On Linux, Cloudflare Tunnel installs itself as a system service using systemctl
. By default, the service will be named cloudflared.service
. To configure your tunnel on Linux:
-
Open
cloudflared.service
. -
Modify the
cloudflared tunnel run
command with the desired configuration flag. For example, -
Restart
cloudflared.service
: -
To verify the new configuration, check the service status:
On macOS, Cloudflare Tunnel installs itself as a launch agent using launchctl
. By default, the agent will be called com.cloudflare.cloudflared
. To configure your tunnel on macOS:
-
Stop the
cloudflared
service. -
Unload the configuration file.
-
Open
/Library/LaunchDaemons/com.cloudflare.cloudflared.plist
in a text editor. -
Modify the
ProgramArguments
key with the desired configuration flag. For example, -
Load the updated configuration file.
-
Start the
cloudflared
service.
On Windows, Cloudflare Tunnel installs itself as a system service using the Registry Editor. By default, the service will be named cloudflared
. To configure your tunnel on Windows:
-
Open the Registry Editor.
-
Go to HKEY_LOCAL_MACHINE > SYSTEM > CurrentControlSet > Services > cloudflared.
-
Double-click ImagePath.
-
Modify Value data with the desired configuration flag. For example,
To configure how cloudflared
sends requests to your public hostname services:
- In Zero Trust ↗, go to Networks > Tunnels.
- Choose a tunnel and select Configure.
- Select the Public Hostname tab.
- Choose a route and select Edit.
- Under Additional application settings, modify one or more origin configuration parameters.
- Select Save hostname.
A remotely-managed tunnel only requires the tunnel token to run. Anyone with access to the token will be able to run the tunnel.
To get the token for a remotely-managed tunnel:
- In Zero Trust ↗, go to Networks > Tunnels.
- Select a
cloudflared
tunnel and select Edit. - Copy
cloudflared
installation command. - Paste the installation command into any text editor. The token value is of the form
eyJhIjoiNWFiNGU5Z...
Make a GET
request to the Cloudflare Tunnel token endpoint:
Cloudflare recommends rotating the tunnel token at a regular cadence to reduce the risk of token compromise. You can rotate a token with minimal disruption to users as long as the tunnel is served by at least two cloudflared
replicas. To ensure service availability, we recommend performing token rotations outside of working hours or in a maintenance window.
To rotate a tunnel token:
-
Refresh the token on Cloudflare:
- In Zero Trust ↗, go to Networks > Tunnels.
- Select a
cloudflared
tunnel and select Edit. - Select Refresh token.
- Copy the
cloudflared
installation command for your operating system. This command contains the new token.
-
Generate a random base64 string (minimum size 32 bytes) to use as a tunnel secret:
-
Make a
PATCH
request to the Cloudflare Tunnel endpoint: -
Copy the
token
value shown in the output.
After refreshing the token,
cloudflared
can no longer establish new connections to Cloudflare using the old token. However, existing connectors will remain active and the tunnel will continue serving traffic. -
On half of your
cloudflared
replicas, updatecloudflared
to use the new token. For example, on a Linux host: -
Restart
cloudflared
: -
Confirm that the service started correctly:
While these replicas are connecting to Cloudflare with the new token, traffic will automatically route through the other replicas.
-
Wait 10 minutes for traffic to route through the new connectors.
-
Repeat steps 2, 3, and 4 for the second half of the replicas.
The tunnel token is now fully rotated. The old token is no longer in use.
If your tunnel token is compromised, we recommend taking the following steps:
-
Refresh the token using the dashboard or API. Refer to Step 1 of Rotate a token without service disruption.
-
Delete all connections between
cloudflared
and Cloudflare:This will clean up any unauthorized connections and prevent users from connecting to your network.
-
On each
cloudflared
replica, updatecloudflared
to use the new token. For example, on a Linux host: -
Restart
cloudflared
: -
Confirm that the service started correctly:
The tunnel token is now fully rotated. The old token is no longer in use.
Minimum permissions needed to create, delete, and configure tunnels for an account:
Additional permissions needed to route traffic to a public hostname: