Skip to content

Cloudflare rocks

Published: at 13:00reading time4 min readSuggest Changes
Cloudflare rocks

Moving my personal website to Cloudflare Workers

For a while, I have been hosting my personal website on GitLab Pages, which is a solid choice for static sites whilst the code is hosted on GitLab, and I appreciate the smooth CI/CD integration. However, I’ve always had an eye on Cloudflare, especially hearing about their generous free tier and the great performance of their edge computing. I’ve even used Cloudflare Pages for dev versions of my site, which was cool. Then I was searching for a custom domain for the website, and ended up on Cloudflare because it was the cheapest option I could find! After I landed on the Cloudflare dashboard, I started exploring their offerings and was impressed by the range of services they provide, with a few clicks I somehow opened the Cloudflare Workers dashboard. Turns out, they’re recommending Workers for all new projects now, even over Pages, because it’s got more features and is where the future development is happening.

Table of Contents

Open Table of Contents

New Workers Worker?

So, I decided to give it a shot. Setup a new Worker was super easy using the Cloudflare UI, I just had to import the GitLab repository, configure some settings, and voilà, I had a new Worker running. Oh, not quiet, I had to add a wrangler.toml file to the repository, which is the configuration file for Cloudflare Worker:

name = "web"
compatibility_date = "2025-03-25"
[assets]
directory = "./static"

What Cloudflare essentially does is added a webhook to the GitLab repository, so every time I push a commit or merged a pull request into the main branch, it automatically triggers a deployment build to the Worker. This is pretty similar to how GitLab Pages works, but with the added benefit of being able to run server-side code at the edge.

Custom domain

You can easily set up a custom domain for the Worker by doing two things:

  1. Add the domain name to the Worker settings in the Cloudflare dashboard.
  2. Create a CNAME record in your DNS settings that points the (www) custom domain to the Worker URL.

The CNAME record looks like this:

Name: www
Type: CNAME
Value: web.my_account.workers.dev
TTL: Auto
Proxied: True

CNAME record Image: CNAME record

New subdomain as a Worker

My personal site isn’t just one thing; I’ve got various static projects living as subpaths. Moving these over was surprisingly straightforward. It basically involved creating a new Worker for each static site I wanted to host as a subdomain. The trick was tweaking the wrangler.toml file (that’s Cloudflare’s config file for Workers). I added specific routes patterns in there to send traffic for each subdomain to its own Worker.

For example, if I wanted to host a static site at wasm-python.ylweng.com, I’d set up the wrangler.toml like this:

name = "wasm-python"
compatibility_date = "2025-03-25"
routes = [{ pattern = "wasm-python.ylweng.com/*", zone_name="ylweng.com" }]
[assets]
directory = "./public"

After getting wrangler.toml sorted, the last piece was to add a CNAME record in Cloudflare DNS for each subdomain. The Name for the CNAME record was just the subdomain itself (like wasm-python), and the Target was set to the URL of the Cloudflare Worker, in this case wasm-python-playground.my_account.workers.dev. In this way, traffic gets routed exactly where it needs to go.

Zero Trust

One of the cool things about Cloudflare is their Zero Trust security model. Everything is laid out in a way that makes it easy to secure your applications. For my personal site, I didn’t need to set up any complex security rules, but I did appreciate the option to add some basic protections like DDoS mitigation and bot management. It’s all pretty much set up by default, which is great for someone who might not be a security expert but still wants to keep their site safe.

Final thoughts

Moving to Cloudflare has been a great experience so far. The performance is solid, the setup was straightforward, and end users are benefit from their edge computing. This means faster response times for users around the world (no more complains from friends on the other side of the earth!). Plus, the free tier is generous enough for my personal projects, so I’m not worried about costs for a while.

One thing I really look forward to is exploring more of what Cloudflare Workers can do. With the ability to run server-side code at the edge, I can start building more dynamic features into my site without having to manage a separate backend server. Though I’m a little frustrated with the build process, which is a blackbox at the moment, and the only thing you can do is pass the build command to the Worker, which is not very flexible. But admittedly, it is still in the Beta stage, so I hope they will improve it in the future.


Previous Post
Actor Model
Next Post
End-to-End Testing with Docker and Selenium