Nginx Counter — DevOps

Set up nginx in a phone shop's back room: root, location, proxy_pass, HTTPS and caching. 16 levels, played right in the browser with nothing to install.

What you learn in this game

nginx takes requests from the villagers' phones and decides the answer itself: a file from the disk, an answer from another app, or an error page of its own. A server block runs one site, and root says which folder its files come from. At Konter Danang Cell every config is run by the real nginx 1.30.6, and the log in the book copies what it did.

One nginx can serve many sites on one IP address. It tells them apart by the Host header the phone sends, which is the site name the villager opened. Each server block names the sites it serves with server_name.

A single-page app (SPA) makes its own addresses in the browser. When the phone reloads such an address, the request reaches nginx, and the disk has no file of that name. try_files tells nginx to try several possibilities, then do something when none exists.

The phone keeps answers in a cache of its own, and the server's Cache-Control header decides how long and how. That cache is not nginx's: once the phone keeps something, the server cannot take it back until its lifetime runs out.

A location block handles part of a site's addresses, everything that starts with /galeri/ for example. Inside it, files can come from another folder on the disk. There are two ways to map an address to a folder, and they differ by one folder name.

One address can match several location blocks at once: the prefix block /galeri/ and a regex block for every .jpg. nginx uses only one, and the rule that picks it is not just the order they are written in. A sign in front of the path changes how a block matches.