Publishing a Website
Let’s say you have an awesome idea for a website. You spun up a VM in cloud and started working on the content for your website. This post is part of https://jigarr.medium.com/list/cloud-made-easy-8c91475ff513 series.
Sample website
If you have created a Linux VM, then you can start a sample hello-world website in minutes by running following commands on the VM
# switch to root user
sudo -i # update packages installed on the VM
yum update -y# install & start httpd service
yum install -y httpd
systemctl start httpd.service
systemctl enable httpd.service# place sample html file
echo "Hello world from $(hostname -f)" > /var/www/html/index.html
You can create a VM with a public IP in the cloud. Assuming that everyone can connect to port 80 of the VM, you can see our sample website via browser. Instead of remembering the IP address of the VM, let’s give it a proper name or Domain Name such as www.jigarrathod.net.To achieve this, you need to buy your favorite domain name. In this case, it would be jigarrathod.net.
A domain name can be purchased via AWS Route53, GoDaddy, Gandi and so on. After placing an order, you will have to wait a little to get the domain name. Consider privacy protection option while buying a domain name. Once you purchased a domain name, you can create your own subdomain such as www.jigarrathod.net or mail.jigarrathod.net and so on.
When you try to buy a domain name, you would see fixed list of suffix such as .net, .com, .edu and so on. All of these suffix are top-level-domain which are controlled by various organization. The list of top-level-domains are mainted by a not-for-profit organization ICANN. If you are curious about buying top-level-domain, checkout application_process_for_tld.
Side Note: What is privacy protection for domain name?
When you place an order to purchase domain name, you have to provide various information like name, address, phone number, email address. These can be looked up by WHOIS directory (can be lookedup by Godaddy_whois). Using privacy protection, you would be able to hide information on WHOIS directory. I am sure that this information can be revealed depending on the case.
After purchasing a domain name,
- we need to bind the domain name with machine or machines that are running our website
- we also want to make sure that when other people go to www.jigarrathod.net they connect to a VM. The trasnlation from website to IP address is done by a resolver. Internet Service Providers run resolver to help their customers. Following command can the translation process
$ dig +trace www.google.com
. 8768 IN NS i.root-servers.net.
....
com. 172800 IN NS a.gtld-servers.net.
....
google.com. 172800 IN NS ns2.google.com.
....
www.google.com. 300 IN A 142.250.81.228
Look at the first and last column of the output. The resolver first picked a server by looking up .
and found i.root-server.net which is a one of the 13 root servers in the world. The full list of root servers can be found at IANA.
Resolver queried com.
to i.root-servers.net
and found a.tld-servers.net
. Afterwards, resolver looked up google.com
and found ns2.google.com
. The last line for www.google.com
has an actual IP address. A
in front of the IP address stands for Address and NS
stands for Name-Server.
i.root-server.net
, a.tld-servers.net
and ns2.google.com
are name-servers. Internet Service Providers usually stores such popular websites in a cache to save time. The number following google.com represents when refresh time and is known as Time-To-Live (TTL).
ns2.google.com
is a Name-Server (NS
) owned and maintained by google
. it contained A
Address record. There are various types of record a name server can hold such as AAAA
, CNAME
, MX
, NS
and so on.
After purchasing a website, we need to setup our NameServer. In case of, AWS name servers are managed by a service called Hosted Zone. A user can add A
, AAA
, CNAME
and other type of records. To associate www.jigrrathod.net with the public IP of my VM, I would simply add A
record as following:
In this post, I covered following concepts
- Domain Name System (DNS)
- Top level domain
- WHOIS directory — contains information about the domain owner
- NameServer — NS
References
Head First for networking — Chapter 8 — The Domain Name Sytem: Names to Numbers
Learning CoreDNS - by John Belamaric, Cricket Liu — Chapter 2 — A DNS refresher
Learning DNS — Course by Cricket Liu — Published by Infinite Skills
Route 53 AWS re:Invent 2016 — https://youtu.be/AAq-DDbFiIE
Route 53 AWS re:Invent 2020 — https://youtu.be/E33dA6n9O7I
ICANN — not for profit organization
Application process for a new top level domain — https://newgtlds.icann.org