Mikey’s Linux Field NotesAll topics

GUIDE 11 / WEB SERVICES

Nginx & HTTP

Serve static pages, understand responses, and inspect requests without guessing.

4 quick lessons · Examples to adapt to your server
In this guide
Check configuration and service stateMap a URL to a document rootInterpret HTTP resultsRead the evidence in logs

Commands use class paths and example filenames. Replace placeholders and inspect the target before making changes.

01

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.

COMMANDS & EXAMPLES
sudo nginx -t
systemctl status nginx --no-pager
sudo ss -tlnp | grep nginx
curl -I http://localhost
Field note

Only run sudo systemctl reload nginx after the configuration test succeeds. Static HTML and CSS edits normally do not require a reload.

02

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.

COMMANDS & EXAMPLES
curl -I http://localhost/
curl -I http://localhost:8080/
curl -I http://localhost:8080/TLCL-25.12A.pdf
grep pdf /etc/nginx/mime.types
Field note

Include /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.

03

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.

COMMANDS & EXAMPLES
curl -I http://localhost/nosuchpage.html
curl -f -s -o /dev/null --max-time 5 http://localhost/
echo $?
Field note

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.

04

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.

COMMANDS & EXAMPLES
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.log
Field note

Use 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.