1/20
Looks like no tags are added yet.
A colleague says the site is down. What is the first thing you look at?
the log
What two logs does Nginx write and what are they for?
The access log records every request: client address, time, request line, status, bytes, referrer, user agent (the default combined format).
The error log records why: it has a severity (error_log file level;) and names the file, rule or upstream involved
What does the status code 301/302 tell you?
a redirect (correct if you meant it)
What does the status code 403 tell you and what are the three causes for it?
forbidden, which has three different causes with three different error-log lines (file permissions, a missing index with listing off, an allow/deny rule)
What does the status code 404 tell you?
nothing at that path (wrong root, wrong URL)
What does the status code 502 tell you?
Nginx could not get an answer from a backend (a proxy_pass target down)
What does the error code 504 tell you?
the backend answered too slowly
What does the error code 200 tell you?
A request answered by the wrong site is a 200 for the wrong content: only the server block that logged it tells you
What does an empty error log next to a 404 tell you?
check the configuration with nginx -T, not the log. A location that uses try_files ... =404 returns its 404 without writing anything to the error log
How are allow and deny checked?
allow and deny are checked in order, first match wins, like an ACL: allow <lan>; allow <partner>; deny all;
What does proxy_pass do?
proxy_pass hands a location to a backend; with the backend stopped you get a 502 and the error log names the refused connection
What same six steps of troubleshooting do you need to work through every time, without skipping to the fix?
(1) Reproduce the symptom: run curl -I with the same name and address the user used, and note the status
(2) Access log, did the request arrive and which block answered? sudo tail -n 5 the site's access log; if the request is not there, look in /var/log/nginx/access.log: the default site answered, so suspect server_name
(3) Error log, why? Read the line written at that moment; it names the file, rule or upstream involved
(4) Configuration, is Nginx set up the way you think? nginx -t finds syntax and path errors; nginx -T | grep -E 'server_name|root|listen' shows what is really in effect
(5) Fix one thing, run nginx -t, then reload
(6) Prove it with the same curl as in step 1
What happens if nginx -t fails?
a reload is refused and the old configuration keeps running; a restart would stop Nginx and then fail to start, taking every site down
Three different problems produce a 403. How did the error log tell them apart?
file permissions, a missing index with listing off, or an allow/deny rule: each writes a different error line
What did nginx -t catch that a reload would have turned into an outage?
a bad certificate path: the reload is refused and the old configuration keeps running, but a restart would have taken the site down
What is the likely cause and fix for the following issue: Error log is empty despite a failure
The error_log directive is in a different block, or the fault is not an error (wrong server_name)
Check which block logged the request; read the global error log as well
What is the likely cause and fix for the following issue: The partner gets 403 for their own address
The partner address in the allow list is wrong
Use the address in the access log's first field
What is the likely cause and fix for the following issue: S2 gets 403
The LAN is missing from the allow list, or deny all is first
Allow rules must come before deny all
What is the likely cause and fix for the following issue: Reload fails after the certificate fault
Nginx cannot load the bad path
Fix the path, then nginx -t and reload; do not restart blindly
What is the likely cause and fix for the following issue: No 502 appears
The backend is still running, or the location is not matched
Stop the backend; confirm the location in nginx -T
What is the likely cause and fix for the following issue: The site log shows the wrong host
A different server block answered
Check nginx -T | grep server_name and the log file that was written