Troubleshoot Nginx Static Website 403 and 404
Start with the exact failing request
For this static site, a missing file normally produces 404 Not Found. A request to an existing directory with no index and directory listing disabled can produce 403 Forbidden. A permissions problem can also cause 403. These codes are clues, not unique diagnoses; other modules or error handling can change the result.
curl --noproxy '*' --max-time 2 -i http://127.0.0.1:18085/index.htmlcurl --noproxy '*' --max-time 2 -i http://127.0.0.1:18085/missing.htmlcurl --noproxy '*' --max-time 2 -i http://127.0.0.1:18085/no-index/All commands in this chapter are optional, for the supplied Chapter 5 lab only. Use a reviewed patched Nginx build in an approved disposable Linux VM as a non-root user. Follow the lab README to copy the files, set LAB, prepare directories, confirm port availability and test the complete configuration. Results are predicted, not observed. In the baseline lab, the first returns 200, the second 404, and the third 403. The third directory exists and contains a text file, but no configured index. autoindex off prevents Nginx from generating a listing.
root html;index index.html;autoindex off;Check the file path and worker access
Work from the effective configuration. If the root is html, check whether html/assets/site.css exists. A misspelled root or a case mismatch on a case-sensitive filesystem can lead to a missing path. The worker process must be able to traverse parent directories and read the intended file. Do not assume a readable file is reachable through every parent directory.
ls -ld "$LAB" "$LAB/html" "$LAB/html/assets"ls -l "$LAB/html/assets/site.css"These commands show directory and file permission bits for the lab paths; they do not prove the worker identity or all applicable access controls. Verify the actual worker account and any relevant ACL or mandatory access policy in the approved environment. If the wrong root is configured, fix the root rather than broadening permissions.
Use request and error logs together
tail -n 10 "$LAB/logs/access.log"tail -n 10 "$LAB/logs/error.log"The access log records requests and their final status. The error log can explain why a path could not be opened or why listing was denied. A message may vary with the installed build and OS. Match the request to its time and path rather than assuming the newest error is the one you need.
GET /index.html -> 200GET /missing.html -> 404 (file not found)GET /no-index/ -> 403 (directory index unavailable)Avoid chmod 777, public directory listings, running workers as root, or serving a private parent directory to make an error disappear. Make the smallest appropriate correction and verify both successful and rejected requests.
Practice: choose a minimal fix
A correct stylesheet exists under html/assets but your request uses /style.css. Identify the mismatch, correct the URL, and design checks for the page, stylesheet and missing path. If no-index/ should be a public page, add a reviewed index file instead of enabling a listing. Next: HTTP requests and responses.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Static website troubleshooting
Check the concepts taught in this lesson.
What status should /missing.html return in the baseline lab?
Why does /no-index/ produce 403 in this lab?
Which additional permission matters when reading a file?
What is the first useful check after an unexpected static 404?
Which evidence can help explain a failed file open?