Domain

What Is Domain

google.com is a domain, bing.com is another.

There can be sub domains, like news.google.com, maps.google.com, but they all belong to the same google.com domain.

How Does It Work

When user put www.example.com into the browser, the browser does not know about that "example" website, it will ask the DNS(Domain Name System) server where to go. DNS server will lookup www.example.com in its records, if it finds one, it will "resolve" the string into an IP address, so the browser can send the request to that IP and retrieve the content(HTML, images, etc).

Awesome! Where To Register Your Own Domain?

There are a few options, the prices and capabilities vary.

  • GoDaddy

    • can be very cheap for the first year
    • price may go up for the following years, keep an eye on your bills.
    • your information is public
  • Google Domains

    • transparent and consistent price: $12 for .com, for example
    • you can make your information private without extra expense.

Setup DNS

Once you have your domain registered, you can config the subdomains and other settings. A few terms to clarify:

  • A: map from subdomain to IPv4
  • AAAA: map from subdomain to IPv6
  • CNAME: map from subdomain to other domain or subdomain

The following sections illustrate how they can be used.

A/AAAA If You Know The IP

Use A(IPv4) or AAAA(IPv6) record since you know the IP

  • www.mydomain.com -> xxx.xxx.xxx.xxx
  • app.mydomain.com -> xxx.xxx.xxx.xxx

You can also point multiple subdomains to the same IP. All of the traffic to www.mydomain.com and app.mydomain.com will be sent to that IP, then it is HTTP server's job to find the right sub domain(www or app)

CNAME If You Are Using Another Service

By using Heroku or Github Pages or GitBook, you do not know the IP, so use CNAME to create an alias for each

  • docs.mydomain.com -> <username>.github.io
  • app2.mydomain.com -> app2.herokuapp.com

Forward

Using A/AAAA/CNAME will not modify URL, however Forward will redirect user to a different URL