GUIDE 11 / WEB SERVICES
Nginx & HTTP
Serve static pages, understand responses, and inspect requests without guessing.
In this guide
Commands use class paths and example filenames. Replace placeholders and inspect the target before making changes.
Check configuration and service state
Validate the configuration before reloading it. A successful syntax test does not guarantee that every page exists or that clients can reach the server.
sudo nginx -t
systemctl status nginx --no-pager
sudo ss -tlnp | grep nginx
curl -I http://localhostOnly run sudo systemctl reload nginx after the configuration test succeeds. Static HTML and CSS edits normally do not require a reload.
Map a URL to a document root
A server block selects the listening port and hostname; root maps request paths to files. The main site uses /usr/share/nginx/html. The class documents site uses /usr/share/itfdn-docs on 8080.
curl -I http://localhost/
curl -I http://localhost:8080/
curl -I http://localhost:8080/TLCL-25.12A.pdf
grep pdf /etc/nginx/mime.typesInclude /etc/nginx/mime.types inside http so a PDF receives application/pdf. A fallback default_type can cover extensions without a mapping. Do not put private keys, shell histories, or credentials under a document root.
Interpret HTTP results
200 means a successful response. 301/302 indicate redirects. 403 means access was forbidden, and 404 means no matching resource was found. curl -I requests headers with HEAD.
curl -I http://localhost/nosuchpage.html
curl -f -s -o /dev/null --max-time 5 http://localhost/
echo $?Without -f, curl can exit successfully after receiving an HTTP 404. A missing favicon often causes a harmless 404 separate from a successful homepage request.
Read the evidence in logs
Access logs show client address, time, request, status, and other fields. Error logs can explain filesystem access failures. A client string alone cannot prove who visited.
tail -n 20 /var/log/nginx/access.log
tail -n 20 /var/log/nginx/access-8080.log
tail -n 20 /var/log/nginx/error-8080.logUse sudo if your account lacks access. An ACL can grant read access without changing ownership. Internet scanners also visit public sites; coordinate with a classmate before labeling an unfamiliar address as their visit.