Academic Blog by Shuo Feng.

Published on:

Using Cloudflare Tunnel for Homelab Access

How I turn an idle laptop into a versatile server using Cloudflare tunnel, code-server, Grafana, WordPress (and more)

Background

Recently, I purchased a Samsung Galaxy Tab S8 Ultra on a whim for a great deal, thanks to my awkward nature. After calming down, I had to think about how to put this thing to good use.

This device has a gorgeous screen both in size and quality, excess performance for a non-professional user like me, and a mediocre operating system compared to iPadOS. When it comes to the battery life, however, things changed.

So far, I have a ThinkPad ThinkPad X1 Titanium Yoga Intel i7 11gen, a high-performance laptop Gigabyte AERO 16 Intel i7 12gen w/ NVIDIA RTX 3070 Ti, and an old 11-inch iPad Pro 2018 without a keyboard. Both of them cannot last long for tasks like note-taking, writing or working on remote devices. Rightfully so, my new friend fills that void. Therefore, after getting familiar with software like Obsidian, Termius, Samsung Notes, and Samsung dex etc., I decided to take one step further.

Host a Visual Studio Code

Usually, I spend almost half of my time on this highly acclaimed text editor for LaTeX, blog posts and programming languages that are not well supported by JetBrains’ IDEs. Therefore, I like the idea to access a familiar environment wherever I want. Ode to hundreds of contributors from the project `coder/code server, I easily made it comes true.

Back to the hero image of this post, it shows that I was using VSC in the Chrome browser to set up a latex environment on Debian 12. It was stable I broke the latex environment on Arch Linux a few days ago after a yay (yet another yogurt) 😊 and extraordinarily easy. The experience, on the other hand, was truly beyond my expectation.

code-server in the browser

At the very beginning, I wrote latex on Overleaf, which provides the best experience compared to other IDEs online or locally. Unfortunately, I cannot afford the subscription fee even though they provide a student promotion. On the contrary, running the latex compiler on a physical machine is not that convenient although it supports tools like git without any cost. Therefore, after taking all these annoying things into account, I finally find my promising land.

Host Grafana for Monitoring

Grafana

My next goal is to find a modern way to monitor system resource, grafana/grafana fits all my needs and more. It’s pretty easy to set up the necessary toolchain to get a fancy dashboard on Debian 12.

In short, you can install all packages via apt without bothering with some tedious configuration. The only thing I did is to follow the official doc.

One thing that didn’t mention by the docs is those two packages below:

  1. prometheus tracker.debian.org
  2. prometheus-node-exporter tracker.Debian.org

The dashboard I use is node-exporter-full, which is ranked first in its category.

Deploy Cloudflare Tunnel for Accessibility

Until now, I basically put up a rough home lab … that resides locally in your home and where you host several applications and virtualized systems for testing and developing or for home and functional usage …, but in order to reach its full potential (which still didn’t achieve when I was writing this post) I have to make it accessible wherever I am.

My first choice is Cloudflare Tunnel since I have already stuck to other services it provides. It’s not the perfect solution to be honest, because all traffic has to go through CF, which causes noticeable delays even if the device is only one meter away. However, it won’t affect anything unless I input commands in the terminal directly. In the end, it defeats other candidates like Tailscale to avoid uncertainties, and I may try other tools like tabverse when it’s necessary.

After all these steps, I can finally host something like WordPress on this machine.

To be continued…