As you may have noticed from the URL you’re visiting, I have my own domain. I’ve been using it only for this website but I thought: why not create a subdomain which I can use for my self-hosted services?
My previous setup was a bit messy and not powerful enough to have a configuration for my root domain and a separate one for my services subdomain. After searching around for a good solution, I ended up picking Cloudflare: the free tier is more than enough for what I need.
The first thing to do was configure Cloudflare’s nameservers for my domain: the procedure is really simple but it depends on the domain provider you’re using. Simple but slow: updating DNS can take up to 24/48 hours!
While I was waiting for the change to be effective I configured my DNS records on Cloudflare like this:
Type | Name | Content |
---|---|---|
CNAME | pgentili.com | pgentili.netlify.com |
CNAME | www.pgentili.com | pgentili.netlify.com |
A | *.subdomain.pgentili.com | static_ip |
This means every access to my root domain will be redirected to my hosting service of choice (Netlify, highly recommended), while every access to my subdomain will be resolved to a static IP. Awesome!
But what if you, like me, can’t really obtain a static IP from your ISP? Cloudflare supports Dynamic DNS: using a dedicated API it is possible to update the target static IP periodically. The official documentation proposes different methods but I ended up using a simple application available as a Docker image: once configured it updates the DNS entry of choice every 5 minutes.
Finally, why not set up e-mail redirection? From the configuration panel, it’s easy to configure custom addresses like email1@example.com, and email2@example.com which can be redirected to your personal e-mail. This will result in some other entry in the DNS panel which I won’t report for simplicity. You can now send me an email to blog@pgentili.com and it’ll be redirected to my personal one.
Of course, this is not a sponsored post, just a happy user sharing his own experience. Happy hosting!