When sharing our server with others, we typically want to share a human-readable address such as a domain name instead of an IP address. This module will review how to buy domain names and configure them to reference the IP addresses of our machines in the cloud.
Buy a Domain
We can buy domains on domain marketplaces like Namecheap, GoDaddy, and Google Domains, and associate them with our servers. RA will use Namecheap for our examples, but other marketplaces should have similar functionality.
The link from our domain name to server will break if we restart our EC2 instance, because AWS assigns a new public IP each time we start an instance. If we need an IP address that persists across restarts, we can use AWS Elastic IP.
If you haven't already, create an account on namecheap.com and buy a domain. The cheapest domains are here. Feel free to use another domain marketplace if you prefer; RA's docs will reference Namecheap.
Configure DNS Settings
Each domain marketplace will also allow us to configure DNS settings for domains we purchase. These DNS settings tell global DNS providers which IP addresses are linked to our domains.
We must configure DNS settings with our domain provider to link our domain with our IP address.
After buying a domain, visit the Advanced DNS tab on the Domain List page.
Delete the default DNS records that are no longer relevant.
There may be a popup to confirm deletion. Click Yes.
Create a new DNS record by clicking Add New Record.
Set the record type as an A record. A stands for "alias", i.e. the domain is an alias for our IP address.
Set the host to @. The host field is where we might name subdomains, e.g. rocketacademy.co has a DNS record with host "bootcamp" for bootcamp.rocketacademy.co. @ represents "this domain", i.e. the domain we purchased without any subdomain prefixes.
Add our EC2 instance's public IP address.
Click Save All Changes.
Assuming our server is running on our EC2 instance, we should soon be able to send requests to our server using the domain name we purchased. Based on the example screenshots above, the URL might look something like http://banana.loan/index.html.
Our DNS settings will take some time to propagate, because our DNS provider's DNS servers need to update the DNS servers of other DNS providers across the world. In the worst case it can take multiple days. So far at RA it has taken anywhere between minutes and hours.