“If you need a machine and don’t buy it, then you will ultimately find that you have paid for it and don’t have it.”
Henry Ford, via Clayton Christensen

These days I’m working on an HTTP server in C using WebSockets, just to get a taste of how things work under the hood.
The only functionality of the server is to listen for incoming requests and send HTML and media files.

Cloud services have become extremely popular due to accessibility, scalability, and the fact that real hardware is abstracted away from developers.
I wanted to see for myself what it’s like to self-host on a bare-metal server — even though it’s a small project.

At this point, my servers are sitting idle anyway, so why not?


Note

I over simplified all the steps which it took me hours to figure it out! but once you get it that it ;) If you are planning to self-host your personal projects, the steps are pretty much the same for any vps or physical machines all you need is a host.

1.Get a Machine

  • Cheapest way to get started is buy a rasperry pi with minimum 4gb ram and flash a light-wegiht linux destro(headless) where you opereate completley from cli
  • Perfect for personal or hobby projects
  • Great first step into homelabbing

Alt text

VPS (Platform as a Service)

You can rent a VPS from popular providers such as:

  • Linode
  • AWS EC2 or similar cloud services
  • DigitalOcean
  • Hostinger
  • Vultr

For Front-End Developers

You probably don’t want to manage your own server.
In that case, serverless platforms handle deployment automatically.

These are the easiest options for frontend-focused developers:

  • Vercel
  • Netlify
  • AWS Amplify

Though most of these services are basically just wrappers around AWS, offering a nicer UI and developer experience — while charging more for the convenience.


2.connecting to the internet

I had no idea where to begin, so I researched for a couple of days about self-hosting.
Here’s what I concluded:

  • Hosting typically involves port forwarding
  • You need a static IP
  • Most telecom providers don’t give static IPv4 addresses for home consumers
  • Because they use CGNAT (Carrier-Grade NAT)

Even I didn’t know what that actually meant .

Then I discovered web tunnels, where you forward all incoming traffic to a server running on your localhost.

Note: Tunnels are okay for demos.
Not recommended for production if you expect a significant amount of traffic.

so i created a tunnel service on cloudflare (free of cost btw) and run the cloudflared(dameon) basically a way of communication between my machine to the cloudflare servers that gonna forward the request running on specific port on my local machine Everything worked fine, and now I just needed a process that always runs on boot without user interaction — a daemon process in Linux.


Daemon

Alt text

“A daemon is a background process that handles requests for services like file transfers, printing, or managing network connections — kind of like a waiter at a restaurant, serving requests without you ever noticing.
The word itself comes from ancient Greek, meaning an attendant spirit.
Invisible, but always there.
My daemon — it’s always there too. Watching. Guiding. Sometimes I think about how much like them I am… always running in the background.”
Elliot, Mr. Robot


3.Creating Your Own Daemon

I SSH’d into my remote machine (btw, SSH also has its own daemon called sshd, which listens for incoming connections. Here’s what I learned about making a daemon service of your own:

Create a new service file

sudo vim /etc/systemd/system/<name>.service
  1. Configure it

Set: executable path working directory restart policy

From this point, managing your custom service is just like any other daemon:

sudo systemctl start <service>
sudo systemctl status <service>
sudo systemctl enable <service>

If you run into problems:

journalctl itself is powered by its own daemon that logs system events.

sudo journalctl -xe

4.Buy a Domain

well with out domain people cant find you on the internet buy a domain which i strongly recommend if you are in to web programming and single domain can be used to host multiple web application and static site anyway and point the dns to the tunnel on cloud flared admin zero trust panel

NOTE: This more complicated than i mentioned above admin pannel is over-whelming for first time

5.share every where

It’s not that hard — and it is truly rewarding to spin up your own server. Results were satisfying.And its not less than a wonder to realize how internet works

You can check my project(self-hosted) : https://album.wannabex.sbs

Topics I’m Exploring

1. Threads & Mutexes
2. Load Balancers
3. Containerization
4. Socket Programming
5. os and kernel