This document is a supporting document for the project Repurposing My Old Phone into an ARM Linux Web Server. This document is about buying a domain name, configuring DNS, and applying the security features provided by the DNS registrar.
NOTICE: DNS SECURITY CONFIGURATION IS NOT A SUBSTIUTE FOR HARDENING AND SECURING YOUR SERVER. Please follow Security Hardening and Assessment of a Self-Hosted ARM Linux Web Server if you need help securing your server.
Buying a domain is not strictly necessary, so before you spend any money, learn what happens if you buy a domain vs if you don't below.
At the most basic level, your server is reachable through an IP address. A domain name provides a human-readable name that DNS can resolve to an IP address. Which means, just knowing the IP address is enough to visit a website. For instance, to visit www.google.com, you could put 142.250.65.78 (this may change as time passes) in the URL bar and you land at www.google.com. So why buy a domain name, since IP address is free(not quite)?
If you skip buying a domain, and just get an IP address, you should tell people that your website is at xxx.xxx.xx.xx instead of saying your website is at www.awesomecoolreader.com. The problem is that people can't remember IP addresses as easily as website names, and if you can't obtain a static IP address (common case in residential networks and home labs), your website's IP address keeps changing, so today it's xxx.xxx.xx.xx, tomorrow it is xyy.yy.yx.xy. So, people can't access the website after the IP address has changed, and worse, even you can't access it before you figure out what it has changed to. There are many other reasons why DNS servers are used to resolve domain names into IP addresses instead of just using the IP addresses, but these two reasons should help you make your decision. If you don't care about other people visiting your website, you can skip buying a domain name, but if you want easier access, and want to present it to people, buying a domain name is a better choice.
Here is the a better explanation that you will definitely understand.
Buying a domain name:
Running straight up IP address:
Yes, you read that correctly! you can get domain names for around 10$ a year (do look at the renew cost tho). So if you decided to buy a domain name, you can follow along with the rest of this section. But if you decided to not buy a domain name right away, I want to tell you to not worry about it and still follow along with this section in case you ever change your mind.
You can do your own research and find an fitting domain registrar. For me, it was Cloudflare Registrar. I wasn't picky about the registrar for my first website, but Cloudflare Registrar exceeded my expectations. The amount of support, and security you get from Cloudflare just by buying one of their inexpensive domain names is huge. So follow me if you picked Cloudflare Registrar too. If you decided to go with another registrar, this document can still provide you with some valuable information.
You can search Cloudflare Registrar in google, then navigate to products, or follow the link https://www.cloudflare.com/products/registrar/. Then search for the domain name you want to obtain. You might not find the exact domain name you were looking for in which case you have to make a little tweak on the name like you did when you made your Instagram account. There are a lot of options including different TLDs (the thing after the .), but to increase your aura, you can try and get the .com TLD. www.awesomecoolreader.sketchyTLD might raise some side eyes, whereas www.awesomecoolreader.com is easily accepted. I am buying the name sushantadk.com.
Find the name you like, then give Cloudflare all your info and money and you should be good to go!
For people to visit your website through the domain name, the domain name needs to know where your website is. So, we need to assign an IP address to the domain name.
DNS servers host data in zones. Right now, we are only concerned with the A zone. This zone is also called a host record which records the hostname and IPv4 address. When a DNS client queries the name using forward lookup request, DNS responds with the IPv4 address from this record.
To assign the IP address, let's first login to Cloudflare Registrar. On the right sidebar, click on Domains, then overview. Find your domain and click on it. Again, from the sidebar, click DNS then Records. Choose the option to Add record. Select:
My domain registrar is Cloudflare, which provides decent security features. The way I'm configuring security is by looking through every option availabe in the Clouflare website, but I will document only the security related, and standard first website configuration under the free plan here. It might seem like an overkill but for a first time configuration, I see it as an necessary step.
Let's login on the Cloudflare website, and on the right sidebar, let's go to Domains->Overview->yourDomain.
The overview shows that over the course of a week, my website received 561 visitors. A handful of these, possibly 61, were likely my friends and family. I can tell because July 23 is when I announced my website on my IG and I had 61 unique visitors that day. After July 23, the number of unique visitors dropped to 0 for two days, and exploded after that. I suspect July 26 is when automated crawlers and scanners discovered my website, although this is only a hypothesis based on the traffic pattern.
Couldn't it be regular people searching and browsing on the internet? Well, I'd be very flattered if my website can get around 500 views every week but I dont't think that's the case. My website isn't currently appearing in Google search results, and I haven't submitted it to Google's indexing tools yet. So for anyone to access my website, they need the exact domain name, and I fear the bots have discovered just that.
The internet is full of automated scanners preying on websites and servers with weak security controls. Even though some visitors may not have malicious intent, we have to be prepared for the worst case scenario. Following list is what I did on this page, you may need to tweak some things to match your needs.
Under AI crawl control -> Overview, enable 'Managed robots.txt'. Next, the trace feature under Investigate looks interesting. It is still in beta version as of this writing, and I don't need to trace anything right now but I will definitely come back to check on this later.
Moving on to Analytics->Dashboards, it says that we don't have a dashboard yet. Let's change that. Click on 'Create a Dashboard', and from the available templates, add Security Overview, Traffic Overview, DNS Analytics, and Error Monitoring. These are self explanatory dashboards, and they can provide you quick and easy access on a specific aspect, like security, on your website.
For the SSL/TLS section, make sure you have installed a certificate from a publicly trusted CA or a valid Cloudflare Origin CA certificate on your origin server. You can find visit Building a server if you need some help. After installing a certificate, you should be able to use HTTPS traffic. Go to the overview section under SSL/TLS and click on 'configure'. Set the encryption mode to Full (Strict). This encrypts traffic between Cloudflare and your origin and requires Cloudflare to validate the origin certificate.
Let's move on to Security section. When you go to Overview, it gives you a list of recommendations to make your website more secure.
It gave me three recommendations on Bot traffic, and one on Client-side abuse (FYI, some recommendations don't go away even after you implement them). First, I will go ahead and disable access to bots on all pages for the first three recommendations. One thing that stood out amidst blocking access to bots was the Bot fight mode. It says it detects and challenges bot traffic on your domain. Let's enable it and purchase the tickets for the next fight.
The fourth recommendation is about security.txt. For our use case, security.txt is basically the instructions on how people can contact us regarding the security info on our website. Let's go to Review->Go to configure Security.txt. Click on the pen icon next to configurations. Configure it as follows:
Security -> Settings has many settings, most of which are always active and some are reflecting our earlier change. Some of the settings that stood out for me were: Browser integrity check, which evaluates HTTP headers from visitors' browser for threats, and Leaked credential detection, which can help identify login attempts involving credentials that have appeared in known data breaches. We can go ahead and turn these on.
Next, under Rules, go to Overview. You can create different rules for redirect requests, transform requests or responses, and Cloudflare behaviours. I had no reason to put any of these rules in place but if you think you need one, you can create one from scratch or use an existing template.
Let's take a look at Settings -> Managed transforms. All of the settings look useful, but for my website, I enabled only these ones:
These are all the settings that were applicable to my website given its current scope. I intentionally didn't configure every Cloudflare feature available because security configuration should be driven by the requirements of the application rather than by the number of available options. As the website grows, I'll revisit the features I noted and configure them when they become relevant.
To use this domain name to serve a website from a server, visit:
My Website Initial Configuration
Building a server