The goal of this exercise is to set up a real domain name for your application.
- Legend
- 💎 Requirements
- ❗ Choose your subdomain
- ❗ Configure a DNS zone with Gandi.net
- ❗ Access the domain name
- ❓ Adapt your server's hostname
- 🏁 What have I done?
- 💥 Troubleshooting
Parts of this guide are annotated with the following icons:
- ❗ A task you MUST perform to complete the exercise.
- ❓ An optional step that you may perform to make sure that everything is working correctly.
⚠️ Critically important information about the exercise.- 💎 Tips on the exercise, reminders about previous exercises, or explanations about how this exercise differs from the previous one.
- 👾 More advanced tips on how to save some time. Challenges.
- 📚 Additional information about the exercise or the commands and tools used.
- 🏁 The end of the exercise.
- 🏛️ The architecture of what you deployed during the exercise.
- 💥 Troubleshooting tips: how to fix common problems you might encounter.
Make sure you have completed the previous exercise.
In this exercise, you will configure actual subdomains in the worldwide DNS system to point to your server. You must now choose your personal subdomain for this course.
First, select one of the following domains depending on your class:
- Students of the M51/1 class should use
archidep.ch
. - Students of the M51/2 class should use
archidep2.ch
.
Then, choose a subdomain of that domain. For example, you may use the same name
as your Unix user (e.g. jde
), although you MUST replace any
underscores (_
) by hyphens (-
) if you have any.
Alternatively, you can call your server whatever you want, e.g. my-precious
,
as long as it does not conflict with the names chosen by the other students.
For example, your full subdomain should look like jde.archidep.ch
or
jde.archidep2.ch
. Proceed with the next steps once you have decided what it
is.
-
Connect to Gandi.net with the user account provided to you by the teacher.
-
Go under the "Domain" tab in the left menu and select
archidep.ch
orarchidep2.ch
depending on your class (archidep.ch
for M51/1 andarchidep2.ch
for M51/2). -
Go under the "DNS Records" tab in the domain's top menu.
-
Add two new
A
records to map subdomains to your server's public IP address:- Assuming your personal subdomain for the course is
jde.archidep.ch
, you should usejde
as the name of the DNS record. - Then, create a wildcard subdomain using
*.jde
as the name of the DNS record, and the same IP address. This will direct any second-level subdomain likefoo.jde.archidep.ch
to your server.
- Assuming your personal subdomain for the course is
Assuming your server's IP address is W.X.Y.Z
and your username is jde
,
you should have the following DNS records (among others) in the domain's zone
file:
*.jde 1800 IN A W.X.Y.Z
jde 1800 IN A W.X.Y.Z
Once you have configured it correctly, you (and everybody else) should be able to access the todolist application at http://jde.archidep.ch:3000 in your browser (if you have completed the previous exercises).
💎 You might have to wait a few minutes for the change to take effect. especially if you make a mistake in configuring the DNS record and then fix it. This is because DNS records are cached for a time (the TTL you configured), by all intermediaries and also by your machine.
When you originally ran your Microsoft Azure server, you were asked to set a hostname . This hostname is purely informative: it is displayed in the prompt when you connect over SSH but otherwise has no impact on anything else.
However, for consistency, it is recommended that you adapt your hostname to match your personal subdomain.
So if you chose, for example, jde.archidep.ch
, run the following commands
to update the hostname on your server:
$> sudo hostname jde.archidep.ch
$> echo "jde.archidep.ch" | sudo tee /etc/hostname
You have created a mapping in the domain name system between your custom
subdomain (e.g. jde.archidep.ch
) and the IP address of your server.
You have done this by modifying the DNS zone file for the
course's domain (archidep.ch
). When a computer requests to know the IP
address for your subdomain, the DNS name servers of the
domain provider (gandi.net) will give them the IP address in the mapping you
have configured.
This allows your applications and websites to be accessible through a human-friendly domain name instead of an IP address.
This is a simplified architecture of the main running processes and communication flow at the end of this exercise:
The only thing that has changed compared to the previous exercise is that you are now using a domain name instead of an IP address to reach your application.
Here's a few tips about some problems you may encounter during this exercise.
DNS records are cached for a time (the TTL you configured). Your machine has this cache, and all intermediary DNS servers also have it. When you change an existing DNS entry that you have already consulted in your browser, you have to wait for the TTL to expire on your machine and all intermediaries before the changes take effect.
💎 In the meantime, you can simply create a new DNS entry. For example, if you created
jde.archidep.ch
, you can createjde-2.archidep.ch
. This new entry will work immediately. The old one you fixed will work eventually once the cache has cleared.