1 min read

Installing Cloudflare Tunnel on Ubuntu Running on GCP

After configuring Cloudflare Tunnel on several Ubuntu 22.04 servers in Google Cloud, I've developed a simple bash script I use to streamline the process.

To use it, download the script on to your server and configure the following settings to facilitate the installation on your server tailored for a specific service port you intend to map.

At the beginning of the script, adjust the variables to match your Cloudflare DNS settings, eg YOUR.DOMAIN.COM. For Google Cloud Platform (GCP) compliance, modify your domain to fit GCP's naming conventions, eg YOUR-DOMAIN-COM. Next, specify the static external IP address of your GCP VM, eg YOUR_STATIC_IP_ADDRESS, and the service port you wish to direct towards the DNS record, eg YOUR_SERVICE_PORT.

To initiate the installation, execute the following command on your server: sudo sh install_cloudflare.sh.

Following this, you will be guided to paste a URL into your browser that assists in selecting the Cloudflare hosted domain for which you wish to add a Cloudflare Tunnel record. This process also includes the creation of the /etc/cloudflared/config.yml file on your Ubuntu server.

There are all sorts of reasons I like using Cloudflare Tunnel but not having to manage SSL certs is certainly high on my list. If you find a faster way to install and configure Cloudflare Tunnel on an Ubuntu server lmk so that I can use that and take this down. πŸ˜‹