Troubleshoot Multi-site Nginx Hosting and Verify a Safe Reload
A passing configuration test is not enough
Imagine that Book Corner works but Study Notes displays the Book Corner heading. The request returns 200. That means a response was successful; it does not mean the requested site was served correctly. A root pointing to a valid but wrong directory can pass nginx -t.
server_name notes.test;root sites/books;First reproduce using an explicit Host header, then inspect the relevant server block and its root. If both sites return the same heading, compare the actual root and selected server. Do not loosen permissions or change every server block. Fix only the lab notes root.
Test, reload and verify
nginx -p "$PWD/" -c nginx.conf -t# Only after test passes and the lab master PID is verified:nginx -p "$PWD/" -c nginx.conf -s reloadUse the same prefix and config file as the running lab instance. The config test checks syntax and referenced files, not website correctness. The reload asks the master to adopt the configuration; inspect the error log and confirm actual behavior afterward. If the test fails, do not reload. Keep a copy of the known-good configuration.
curl --noproxy '*' --max-time 5 -H 'Host: notes.test' http://127.0.0.1:18131/curl --noproxy '*' --max-time 5 -H 'Host: books.test' http://127.0.0.1:18131/python3 -B verify_live.pyThe expected markers are Study Notes home and Book Corner catalog. The complete checker also verifies CSS types, missing pages, default host and API responses. The optional live commands assume that the approved lab has already been started as described in its README.
Distinguish two kinds of failure
notes.test / 200 Book Corner catalog → inspect notes rootbooks.test /api/nope 404 JSON → app route missingbooks.test /api/books 502 gateway error → check backend/logbooks.test / 200 expected HTML → static path worksThe table contains hypothetical observations. A 502 is not proof of any one underlying cause; investigate the upstream listener and the scoped error log. A healthy static page does not guarantee API availability. A JSON 404 from the app can be correct behavior.
Complete the milestone
Record the original behavior, your hypothesis, the smallest change, syntax result, reload result and request assertions. If a change fails, restore the saved config, test and reload after verifying ownership. Gracefully stop only the lab master and foreground backend, then confirm the lab listeners are gone. Practice: submit the diagnosis and expected verification matrix. The next chapter introduces request variables and map/geo lookups.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Milestone troubleshooting
Choose the best answer for the multi-site fixture.
notes.test returns 200 with Book Corner content. What should you inspect first?
What should happen if the scoped configuration test fails?
After a successful reload, which check matters most?
A static page is healthy but the catalog gives 502. What is the next reasonable step?
Which shutdown procedure is appropriate?