Installing Cloudflared on DigitalOcean Ubuntu
Cloudflared is a tunneling daemon that allows you to securely connect your server to Cloudflare's network without exposing your origin server to the internet. This guide will walk you through the steps to install Cloudflared on an Ubuntu server hosted on DigitalOcean.
Prerequisites
- An Ubuntu server on DigitalOcean
- SSH access to the server
- Basic knowledge of command line operations
Step 1: Update Your System
Start by updating your package lists and upgrading existing packages to ensure everything is up to date.
sudo apt update
sudo apt upgrade -y
Step 2: Install Required Packages
Install the necessary packages to add the Cloudflare repository.
sudo apt install curl lsb-release
Step 3: Add the Cloudflare GPG Key and Repository
Add the Cloudflare GPG key and repository to your system.
curl -L https://pkg.cloudflare.com/cloudflare-main.gpg | sudo tee /usr/share/keyrings/cloudflare-archive-keyring.gpg >/dev/null
Since the noble
release does not have a repository, you can use the focal
release which is often supported.
echo "deb [signed-by=/usr/share/keyrings/cloudflare-archive-keyring.gpg] https://pkg.cloudflare.com/cloudflared focal main" | sudo tee /etc/apt/sources.list.d/cloudflared.list
Step 4: Update Package List Again
Update the package list to include the new Cloudflare repository.
sudo apt update
Step 5: Install Cloudflared
Install the Cloudflared package.
sudo apt install cloudflared
Alternative Method: Using Snap
If you prefer using Snap to manage your packages, you can install Cloudflared via Snap. Ensure Snap is installed and then install Cloudflared.
-
Ensure Snap is installed:
sudo apt update sudo apt install snapd sudo snap install core
-
Install Cloudflared via Snap:
sudo snap install jnsgruk-cloudflared
Step 6: Ensure Cloudflared is in Your PATH
If the cloudflared
command is not found, add Snap's binary path to your system's PATH
.
echo 'export PATH=$PATH:/snap/bin' >> ~/.bashrc
source ~/.bashrc
Step 7: Verify Installation
Verify that Cloudflared is correctly installed by checking its version.
which cloudflared
cloudflared --version
If everything is set up correctly, you should see the path to the cloudflared
binary and its version information.
Conclusion
By following these steps, you can install Cloudflared on your DigitalOcean Ubuntu server, allowing you to securely connect your server to Cloudflare's network. This setup helps enhance your server's security by keeping it hidden from the public internet.
For more detailed information and troubleshooting, you can refer to the official Cloudflare documentation.
References: