It has always pissed me off that you have to pay for hosting. And not a trivial amount, either: around five bucks a month for a really shitty VPS.
Meanwhile, I usually have spare computing power sitting around at home. Old laptops, gaming PCs — all of it gathering dust, despite being a hundred times more powerful than your typical VPS.
So I kept wondering how the hell I could host stuff at home. Deploying apps is straightforward: shove whatever you have into Docker and have it start automatically with the computer. That part was never a problem.
External access, though, was always a pain. First, you need a static IP address. Sometimes it is hard to get, and sometimes you have to pay for it. Second, there is the goddamn NAT. The outside internet cannot reach your internal network because it has no idea where to knock.
Normally you solve this with port forwarding, but that is not always an option. For example, the fiber connection in the apartment I am renting now goes into the ISP’s router, which is password-protected and completely off-limits to me.
Then recently I found a solution: Cloudflare Tunnels. I have been using them for a couple of months now, and I am extremely happy with them.
How does it work? You install a Cloudflare tool on your computer. It automatically maintains a permanent connection to Cloudflare.
You add your domain in the Cloudflare dashboard. Then, with a single command, you can tell it, “Forward requests to this subdomain to a local port on my machine” — and that is it.
It magically starts working. And the best part:
- completely free;
- takes an hour to set up;
- requires zero maintenance and restarts automatically.
If you want to host something locally, here is a detailed guide.