The Desi Architect
Notes / Docker Sandboxes / Nginx Basics: Serve Files, Proxy to an App, Read the Logs, Reload Safely
Docker Sandboxes · Tier 1: Building Blocks · Lab 10

Nginx Basics: Serve Files, Proxy to an App, Read the Logs, Reload Safely

Read an nginx config for the first time. Serve a page, forward /api to a backend with proxy_pass, read the logs, see what a typo and a dead backend do, and reload a new config without dropping a single request.

Time30 minutes
Stacknginx 1.27Ports 18150
MemoryAbout 30 MB
Before thisLab 01Docker Compose Basics
Verified runWindows, Mac, LinuxBash and PowerShell
  1. 1PrepareWhat you will learn
  2. 2PredictGuess before you run
  3. 3RunStep by step
  4. 4ObserveWhat you should see
  5. 5Break itChange one thing
  6. 6Clean upLeave nothing running
On this page
  1. 00 / What You Will Learn
  2. 01 / Why It Matters
  3. 02 / What We Are Building
  4. 03 / Words You Need
  5. 04 / Predict First
  6. 05 / Step by Step
  7. 06 / What You Should See
  8. 07 / Look Inside
  9. 08 / Break It, Fix It
  10. 09 / In Real Projects
  11. 10 / Interview Corner
  12. 11 / Clean Up

00 /What You Will Learn

By the end you will be able to
  • Say what nginx is and what a reverse proxy does.
  • Read a small nginx config: server, location, proxy_pass.
  • Read the access log and the error log.
  • Test a config with nginx -t before using it, and say why that is a habit.
  • Explain 502 and 504, and what nginx does when the backend is down.
  • Reload a config with nginx -s reload without dropping requests.

Before you start

Finish Lab 01 (Docker Compose Basics) and Lab 03 (HTTP, Caching and DNS) first. You should know what a request, a response, a header and a status code are. You do not need to know nginx.