-
Notifications
You must be signed in to change notification settings - Fork 10
Home
This guide provides comprehensive instructions for installing and uninstalling Cloudflare tunnel (cloudflared) on OpenWrt systems. Cloudflare tunnel is a service that proxies traffic to your origin without requiring changes to your firewall, enhancing security and ease of access.
Note: This guide currently supports only Raspberry Pi 4 and x86 versions of OpenWrt.
- OpenWrt: Ensure your router is running OpenWrt on x86 or Raspberry Pi 4.
- Cloudflare Account: Create an account at Cloudflare. The free plan is sufficient for most users.
- Domain: A domain name added to Cloudflare's service with DNS managed via Cloudflare.
- Storage Space: At least 65MB of free space on your device.
- Cloudflare Web Console: Ensure you are logged into the Cloudflare web console for a smoother setup process.
1. Download and Execute the Installation Script
The installation script install-cloudflared.sh
automates the installation process for cloudflared. You can find the script in the GitHub repository: Coralesoft/OpenwrtCloudflare.
2. Configuration Options
The installation script offers two configuration paths:
- Locally Managed Configuration: All configurations are done locally on your device.
- Web Console Managed Configuration: Configurations are managed via the Cloudflare web console.
A. Locally Managed Configuration
-
Start the Installation Script:
- Download and run the
install-cloudflared.sh
script from the GitHub repository.
- Download and run the
-
Login to Cloudflare:
- The script will prompt you to log in to your Cloudflare account via a provided URL.
-
Create a Tunnel:
- Enter a tunnel name when prompted.
- The script will create the tunnel and configure DNS records to route traffic to the tunnel.
-
Generate Configuration File:
- The script will generate a
config.yml
file in/root/.cloudflared/
with the necessary settings. - Update the
ingress
section in theconfig.yml
file as needed.
- The script will generate a
-
Set Up and Start the Cloudflared Service:
- The script will create a service script to manage cloudflared as a service on OpenWrt.
- Enable and start the cloudflared service using the generated script.
B. Web Console Managed Configuration
-
Start the Installation Script:
- Download and run the
install-cloudflared.sh
script from the GitHub repository.
- Download and run the
-
Select Web Console Managed Option:
- Choose the Web Console Managed option when prompted by the script.
-
Create a Tunnel in Cloudflare Web Console:
- Log in to your Cloudflare account and navigate to the Zero Trust Dashboard.
- Create and name your new tunnel.
- Copy the provided token and enter it when prompted by the installation script.
-
Set Up and Start the Cloudflared Service:
- The script will create a service script to manage cloudflared as a service on OpenWrt.
- Enable and start the cloudflared service using the generated script.
3. Final Configuration
For Locally Managed Configuration, configure the /root/.cloudflared/config.yml
file with your specific settings. This file will be generated for you during the installation process.
4. Automatic Updates
The installation script sets up an automatic update service for cloudflared. It checks for new versions regularly and updates the daemon if a new version is available. This ensures that your installation remains up to date with the latest features and security patches.
To uninstall Cloudflared, use the uninstall-cloudflared.sh
script. You can find the script in the GitHub repository: Coralesoft/OpenwrtCloudflare.
install-cloudflared.sh
This script completes the full installation of Cloudflare tunnel onto a Raspberry Pi or x86 machine running OpenWrt. It performs the following tasks:
- Downloads the latest version of cloudflared and installs it.
- Checks if you want to manage the tunnel locally or via the Cloudflare web console.
- Verifies sufficient free space is available.
- Sets up the service to run cloudflared.
- Creates the required configuration in the Cloudflare console and system files.
- Sets up a daily update service to check for new versions and upgrade when available.
uninstall-cloudflared.sh
This script cleanly uninstalls and removes cloudflared from your system.
Following these instructions will help you install and manage Cloudflare tunnels on OpenWrt systems, enhancing your network's security and accessibility. For further assistance, refer to the README.md page in the GitHub repository. For support, visit the OpenWrt forum or use GitHub. For detailed Cloudflare Tunnel documentation, refer to the Cloudflare Tunnel documentation.