0:00–0:10
Recap
0:10–1:50
Lab 4D
1:50–1:55
Bonus
1:55–2:00
Wrap
0:00 – 0:10Recap · 10 min

Log files are the diagnostic tool — walk through the log format before breaking things

0:10 – 1:50Lab 4D · 100 min

Lab 4D — Log format deep dive, 301 redirect verification, four deliberate faults and log-based diagnosis

Part 1 — Log format reference (15 min)

Part 2 — Four deliberate faults and log diagnosis (70 min)

Introduce each fault, observe the symptoms in the browser, then find and interpret the log entry that explains the failure. Fix each fault before introducing the next. Do not introduce multiple faults simultaneously.

Fault 1 — Wrong document root (403/404) (15 min)

Fault 2 — Removed symlink (502/connection refused) (15 min)

Fault 3 — Wrong certificate path (SSL handshake failure) (20 min)

Fault 4 — server_name mismatch (wrong site served / 404) (20 min)

Part 3 — Log analysis summary (15 min)

1:50 – 1:55Bonus · 5 min

Nginx reverse proxy preview

1:55 – 2:00Wrap · 5 min

Learning outcomes — by end of Day 4, students can…

Read and interpret access.logIdentify all fields in a log line and explain what status codes 200, 301, 403, 404, and 502 indicate about the request outcome
Use error.log for root cause analysisFind the specific file path error, permission error, or SSL error that corresponds to a browser failure
Diagnose wrong document rootIdentify a 403 or 404 caused by an incorrect root path from the error.log entry
Diagnose SSL certificate path errorsUse nginx -t output to identify an SSL certificate file not found before it causes a service failure
Diagnose server_name mismatchIdentify when the wrong server block is serving a request and trace it to an incorrect server_name directive

Common issues and fixes

IssueLikely causeFix
error.log is empty despite browser errorsErrors going to the global error log instead of the per-site logVerify error_log directive is in the correct server block (the HTTPS block, not the redirect block). Tail the global log too: sudo tail -f /var/log/nginx/error.log
Fault 2 (removed symlink) shows 200 instead of errorNginx is serving the default page successfully — there is no error from nginx's perspectiveExpected behaviour — Nginx served the default block. The diagnostic is not an error code but the wrong content. Use curl -v to see which server block responded
Python HTTP server for bonus not workingPort 8080 already in use or firewall blocking localhost connectionsCheck: sudo ss -tlnp | grep 8080. Nginx proxy_pass to localhost is not affected by UFW. If port conflict, use a different port in both the python3 command and proxy_pass directive
← Day 3 Lab 4D Handout Day 5 →