Register a domain name
To host a web service, one of the first things you will need to do is
to register your domain name (e.g., example.com
). This will be the
root domain name used for all of your service links and it is part of
what your users will need to type into their web browsers (or click
on) to visit your pages.
--- title: A web browser must query DNS before it can fetch any web page --- sequenceDiagram participant Browser as Web Browser participant DNS as DNS Server participant WEB as Web Server Browser->>DNS: DNS Request (Resolve domain name) DNS-->>Browser: DNS Response (IP Address) Browser->>WEB: HTTP Request (Fetch Web Page) WEB-->>Browser: HTTP Response (Web Page Content)
Domain name registration
The public domain name registration system is controlled as a scarce resource that you must pay for the use of.
If domain names were given out for free, all of the good ones would be taken by now, but due to the imposed registration costs, there are still some good names left to be had. In return for your fee, you receive exclusive control of the domain name for the period that you paid for.
You can never truly own a domain name outright, because you need to keep paying the registrar to keep the record active, so it is best to consider a domain name as a rental service. You may pre-pay for several years in advance or just pay for one year at a time. If you stop paying and the record expires, the name will no longer resolve to your services and you may permanently lose control of the name.
Register an Internet domain name
You can register a domain name from any registrar. For documentation purposes, we will use Gandi.net, but these instructions will be similar regardless of the registrar you pick.
- Sign up for an account at Gandi.net
- Once signed in, from your dashboard, click
Register
. - Search for any domain name you like, e.g.,
your-name.com
. - Add your domain to the shopping cart, go to checkout, and complete your purchase.
- Once you have purchased the domain, it should show up in your
Dashboard
, under theDomain
tab. - Leave this browser tab open, you will return to it in the next chapter.
Transfer DNS to DigitalOcean
All examples in this book use DigitalOcean as the DNS provider. You may choose any DNS service that provides a programmatic API supported by go-acme LEGO.
Sign up for a DigitalOcean account (using this referral link helps support this site).
- Login to your Gandi.net dashboard.
- Click the
Domain
tab. - Find your domain name in the list and click on it.
- Click on the
Nameservers
tab. - Click on the edit button to create new
External nameservers
. - Delete all existing nameservers that may exist.
- Add the following nameservers, specific to DigitalOcean:
ns1.digitalocean.com
ns2.digitalocean.com
ns3.digitalocean.com
Wait a few minutes for the change to take effect, then you can verify
the setting from your workstation using the whois
command:
whois example.com
Domain Name: example.com Registrar WHOIS Server: whois.gandi.net Name Server: ns1.digitalocean.com Name Server: ns2.digitalocean.com Name Server: ns3.digitalocean.com
The output shows a report for your domain registration including the list of the new nameservers.
If you don’t have whois
installed, you can use the web version provided by google.