Before you start
- A payment card.
- The IPv4 address of the server you want the name to point at.
If that server is the g1 VM from the previous lab, read its IP with:
gcloud compute instances describe g1 --zone=us-central1-a \
--format="get(networkInterfaces[0].accessConfigs[0].natIP)"Replace yourdomain.xyz with your own domain everywhere below.
1 — Buy the domain cheaply
- Go to namecheap.com and search for a name.
- Pick a cheap TLD —
.xyz,.siteand.onlineare usually about a dollar for the first year. - Check the renewal price, not just the first-year price. The cheap number is promotional and applies once.
- Skip every paid add-on. Keep the free WHOIS privacy, which is on by default.
- Register for one year. Auto-renew off unless you want to keep the name past the promo.
| Item | What to expect |
|---|---|
| First year | about $1–2 on a cheap TLD |
| Renewal | about $10–14 per year |
| ICANN fee | $0.18, unavoidable |
| DNS hosting | free, included |
| WHOIS privacy | free, keep it on |
2 — Set up the root domain
In the Namecheap dashboard: Domain List → Manage → Advanced DNS.
Delete the two records Namecheap adds by default — the CNAME for www and the URL-redirect record — then add:
| Type | Host | Value | TTL |
|---|---|---|---|
| A Record | @ | your server's IP | Automatic |
@ means the bare domain, yourdomain.xyz.
3 — Add a subdomain
Same screen, one more row. The host field is the subdomain label, nothing else:
| Type | Host | Value | TTL |
|---|---|---|---|
| A Record | lab | your server's IP | Automatic |
That gives you lab.yourdomain.xyz. One A record per subdomain is the whole rule — add www, api, demo the same way.
To point a subdomain at another hostname instead of an IP, use a CNAME record with the target hostname as the value.
4 — Check it resolves
DNS is not instant: minutes usually, a few hours at worst. Check from your own machine:
dig +short yourdomain.xyz
dig +short lab.yourdomain.xyzBoth should print your server's IP. Then open http://lab.yourdomain.xyz in a browser.
sudo sed -i 's/server_name _;/server_name yourdomain.xyz lab.yourdomain.xyz;/' /etc/nginx/sites-available/default then sudo nginx -t && sudo systemctl reload nginx.