>_ IzzyLab

Hands-on task

This task is step 7 of the course “nginx basics”

Fix the broken nginx

medium~10 min

The site is down: nginx won't start because of a broken config, and the document root is missing. Fix the config, make http://localhost/ serve a page with the text It works!, and bring nginx up.

What you'll practise:
  • nginx
  • nginx -t
  • nginx config
  • document root
  • debugging

Topic breakdown

An nginx config is a set of directives with strict syntax, and any typo in a directive name brings down the whole startup. The key skill is iterative debugging via the built-in validator (nginx -t), which names the file and line with the error: you fix, re-check, and repeat until syntax is ok. A separate class of problems is references to non-existent paths: the root directive must point at a directory that actually exists and contains an index.html.

What's checked

  1. nginx config is valid
  2. nginx is running
  3. the page serves It works!

What it looks like