Step 6 of 7 · lab · 20 min
Two sites on one nginx
The blog address opens the company site. Give each name its own site back without breaking the rest.
Situation
nginx on this server hosts two company sites: the main site www.lab.test and the engineering blog
blog.lab.test. The blog recently moved to a name of its own. The main site's files live in /srv/www/main,
the blog's in /srv/www/blog: the home page index.html and the archive archive.html. A request with a name
that no site has gets 404.
The main site opens as usual. But http://blog.lab.test/ returns the main site's home page instead of the
blog.
Both names are in /etc/hosts and point to this same machine, so you can run curl http://blog.lab.test/
right here.
Task
blog.lab.testserves files from/srv/www/blog: the home page and/archive.html.www.lab.testserves files from/srv/www/main, as before.- A request with an unknown site name gets 404.
- nginx is running, and its configuration passes
nginx -twithout warnings.
There is no internet on the machine; everything you need is already installed. Run administrative commands with
sudo.
Lab · on your own
No commands are given in this lab: type them in the terminal yourself. Goals are checked on the machine after every command.
Goals
0 of 4-
blog.lab.test serves files from /srv/www/blog — the home page and /archive.html — not done yet
-
www.lab.test serves files from /srv/www/main, as before — not done yet
-
A request with an unknown site name gets 404 — not done yet
-
nginx is running and its configuration passes nginx -t without warnings — not done yet
The machine is starting
Hints
0 of 3Lab goals
0 of 4-
blog.lab.test serves files from /srv/www/blog — the home page and /archive.html — not done yet
-
www.lab.test serves files from /srv/www/main, as before — not done yet
-
A request with an unknown site name gets 404 — not done yet
-
nginx is running and its configuration passes nginx -t without warnings — not done yet
Goals are checked on the machine after every command.