Linux Labs

Web stack / Stage 1 of 9 · step 6 of 7

Two sites on one nginx

medium ~20 min
Not running Starting usually ~20 s
Report a problem

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

  1. blog.lab.test serves files from /srv/www/blog: the home page and /archive.html.
  2. www.lab.test serves files from /srv/www/main, as before.
  3. A request with an unknown site name gets 404.
  4. nginx is running, and its configuration passes nginx -t without warnings.

There is no internet on the machine; everything you need is already installed. Run administrative commands with sudo.

Visible only to you. Saved as you type.

All notes

Lab goals

0 of 4
  • blog.lab.test serves files from /srv/www/blog — the home page and /archive.html — not checked yet
  • www.lab.test serves files from /srv/www/main, as before — not checked yet
  • A request with an unknown site name gets 404 — not checked yet
  • nginx is running and its configuration passes nginx -t without warnings — not checked yet

Hints

0 of 3 open · they open one at a time
Hint 1
Show the solution after 3 failed checks

Leave the lab?

The machine keeps running for 10 more minutes, then it is removed. Files are lost; completed goals stay.

Loading…