Beginners Guide: How to Configure Cloudflare Tunnels for Your Linux Server

Beginners Guide: How to Configure Cloudflare Tunnels for Your Linux Server


Welcome back to our exploration of enhancing web security and performance! In previous installments, we’ve ventured into NGINX Proxy Manager with Docker Compose and uncovered Cloudflare’s Web Application Firewall (WAF) and Zero Trust Tunnels. Now, it’s time to roll up our sleeves and learn how to employ Cloudflare Tunnels to securely host a web page on your Linux server. Get ready for a step-by-step guide that seamlessly integrates Cloudflare’s technology into your hosting journey.

Setting the Stage: Your Linux Server

Before we dive into Cloudflare Tunnels, ensure you’re prepared with the following:

  • A Linux server boasting a publicly accessible IP address.
  • Uninterrupted SSH access to your server.

Step-by-Step Cloudflare Tunnel Hosting

1. Installing cloudflared:

Start by directly installing Cloudflare’s tunneling software from their repository. Open your terminal and execute these commands:

sudo apt-get update && sudo apt-get upgrade && sudo apt-get install -y cloudflared

2. Authentication Made Simple:

Authenticating your Linux instance with your Cloudflare account is a breeze. Head to your Cloudflare dashboard and follow these steps:

  1. Access Cloudflare Console: Log in to your Cloudflare account and navigate to the Cloudflare Console.
  2. Navigate to Tunneling: In the Console, locate the “Tunnel” or “Tunneling” section.
  3. Create a New Tunnel: Craft a new tunnel if you’re starting fresh and give it a distinctive name.
  4. Add a Public Hostname: While setting up your tunnel, Cloudflare provides the option to add a public hostname. This hostname acts as the bridge between Cloudflare’s network and your server.
  5. DNS Configuration: Follow Cloudflare’s guidance to configure the necessary DNS records for the public hostname. This step ensures that traffic flows seamlessly through your tunnel to your server.
© 2024 Justin Harbour