Deploying Cloudflare Tunnel on Your Own Computer
Introduction
Even though I linked my card to Cloudflare early on, I mostly only used R2. As for Zero Trust, I knew it existed but had never actually used it.
It wasn't until later that I realized this thing can do way more than I thought. So, naturally, I had to start playing around with it.
EP0: Prerequisites
The whole process assumes you already have a Cloudflare account and have your domain's DNS connected to Cloudflare.
First, you'll need a bank card — Visa, MasterCard, AMEX, or Discover, take your pick. Some people said you could use PayPal, but at least when I was linking my card for R2, the PayPal option was already gone. It's a bit hit or miss, honestly. I didn't see the PayPal button, so I just linked a card.
(I used a Bank of China MasterCard.)
If you go the bank card route, remember to keep about 1 to verify your account.
EP1: Initializing Zero Trust
Click the Zero Trust button in the left sidebar, and the page will redirect to Zero Trust's separate console (this console doesn't have a dark mode).
Then you'll see the relevant prompts. Enter a name you think fits — English only.

After entering it, click "Next," then select the Free plan.

Then click "Continue to Payment."

If you linked your card to Cloudflare long ago for some other service, then at this step you can just relax and wait for the status to update.
But if you haven't linked a card yet, it'll pop up and ask you to do so.


When you see the page below, Zero Trust initialization is complete.

EP2: Installing the Software
Click "Settings" → "Resources," scroll down to "Download cloudflared," and choose the download for your system. Here I chose Windows (64-bit).

Once downloaded, open it and install.
You can also deploy it with Docker, but I'll cover that later.
If you need to install via Docker, make sure Docker is installed on your device beforehand. I don't recommend using Docker on Windows for this.
EP3: Creating a Tunnel
Click "Networks" → "Tunnels," then click "Create a tunnel."

Select Cloudflared on the left.

Give the tunnel a name — something easy to remember. I used my device name. After filling it in, click "Save tunnel."

Now for the crucial step.
Open CMD or PowerShell as administrator. If you have gsudo installed, you can just type sudo to switch to admin mode. Since my Windows has gsudo, I just switched directly.

Go back to the previous page and scroll down to "Install and run a connector."
We've already completed steps 1 through 3, so just copy the command, paste it into the console you just opened, and hit Enter.

At this step, in the "Choose your environment" section, there are several options, including Docker. If you switch to Docker, the "Install and run a connector" section below will automatically switch to the Docker instructions. Same as before — just copy the command, paste it into the console, and hit Enter.


After it runs, go back to the previous page and scroll down to "Connectors" at the bottom. You should see your device there.

Once you can see it, click "Next."

Fill in the info as prompted, then click "Save tunnel." After that, visit the link you created to check if everything works.
- If you get an error like
Error: Bad Configuration: Validation failed: parse "http://127.0.0.1:2333 ": invalid port ":2333 " after host, go back to the "Tunnels" page, enter the configuration page for the tunnel you just created, and configure it separately under "Public Hostname." The configuration method is the same as before. This usually fixes the issue. - If that doesn't fix it, make sure your firewall isn't blocking connections related to cloudflared. Generally, Linux systems don't block cloudflared connections.
- On Windows, remember to allow cloudflared through the firewall. Even though cloudflared creates inbound rules during installation, they aren't necessarily enabled.
- Windows users should go to "Windows Defender Firewall with Advanced Security" and enable the two rules named "cloudflared." Usually, enabling them fixes the issue.

Afterword
Cloudflare also recommends creating an application in Access to protect your connection. That's up to you (I didn't do it — I don't know how).
The steps above apply to servers as well (obviously).
Related Links
- cloudflared GitHub repository: cloudflare/cloudflared