From Localhost to Live: Buying a Domain and Setting Up Cloudflare

From Localhost to Live: Buying a Domain and Setting Up Cloudflare
Cloudflare logo

A domain name is your signature on the internet. It’s how people find you, access your content, and remember your site. And the good news? It’s not expensive—buying a domain for a whole year typically costs less than a month of Netflix.

Where to Buy a Domain

There are dozens of domain registrars out there. Some popular options include:

  • Squarespace Domains (formerly Google Domains)
  • Namecheap
  • Cloudflare
  • AWS Route 53
  • Onamae.com (for those in Japan)

The process of buying a domain is as easy as any online shopping experience. You search for the domain you want, check availability, and purchase it.

But make sure you buy from a reliable company, or one that offers features you might use in the future. For example, I originally considered AWS because of its excellent cloud integrations—but AWS doesn't sell .dev domains.

Pro Tip!
If you already have a name in mind—whether it’s personal, brandable, or just really catchy—go ahead and grab that domain now. Good names don’t stay unclaimed for long, and securing it early can save you both regret and money later on.

What is a Domain Level?

A domain has multiple parts:

  • Top-Level Domain (TLD): .com, .dev, .jp, etc.
  • Second-Level Domain (SLD): the name you choose (e.g., christeena)
  • Subdomain: anything before the SLD (e.g., blog.christeena.dev)

Different TLDs serve different purposes and have different availability rules.

Why I Chose Cloudflare

After some research (mostly Reddit rabbit holes), I chose Cloudflare. They’re reputable, the domain buying experience is smooth, and you get access to one of the fastest DNS services globally.

A small caveat: Cloudflare requires you to use their DNS. If you're someone who wants to implement your own or use a different DNS provider, that’s a limitation to keep in mind.

Setting Up DNS Records

Once you’ve bought the domain, the next step is setting up DNS records. These records define how your domain behaves—where it points, how email is handled, and more.

Common DNS Records:

  • A Record: Points your domain to an IPv4 address.
  • AAAA Record: Points your domain to an IPv6 address.
  • CNAME: Points a subdomain to another domain name (like aliasing).
  • MX: Mail exchange records for routing email.
  • TXT: Arbitrary text records often used for verification (e.g., for Mailgun).

Typically, you set an A record like this:

A  |  @ (for root domain)  |  52.52.52.52  (your public IP)

However, since we’re self-hosting from home, pointing directly to your dynamic and potentially changing IP address isn't ideal.

Use Cloudflare Tunnel Instead

This is where Cloudflare Tunnel comes in. It lets you route traffic from your domain to your internal home server securely, without exposing your IP address or dealing with NAT/firewall nightmares.

How to Set It Up:

  1. Install cloudflared on your server.
  2. Set up the config file, usually in /etc/cloudflared/config.yml
  3. Start the service with systemd or manually.
  4. In Cloudflare dashboard, set an A record of your domain (e.g., @) to point to the tunnel.

Alternatively, Cloudflare offers a GUI to create and link a tunnel with just a few clicks.

Finally, map the tunnel to the correct internal port (like 2368 for Ghost), and you’re done. You now have a working domain routed to your self-hosted service.

Conclusion

Buying a domain is the first real step to bringing your blog to the world. And with Cloudflare, it’s not just about pointing a name somewhere—it’s about doing it securely and easily. With DNS and tunnel handled, your domain is now ready to serve traffic to your blog or any other app you're hosting.