NETW 0014 Week 4, Day 4 — Nginx Logs & Troubleshooting

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/20

encourage image

There are no tags or description

Looks like no tags are added yet.

21 Terms

1
New cards

A colleague says the site is down. What is the first thing you look at?

the log

2
New cards

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

3
New cards

What does the status code 301/302 tell you?

a redirect (correct if you meant it)

4
New cards

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)

5
New cards

What does the status code 404 tell you?

nothing at that path (wrong root, wrong URL)

6
New cards

What does the status code 502 tell you?

Nginx could not get an answer from a backend (a proxy_pass target down)

7
New cards

What does the error code 504 tell you?

the backend answered too slowly

8
New cards

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

9
New cards

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

10
New cards

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;

11
New cards

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

12
New cards

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


13
New cards

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

14
New cards

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

15
New cards

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

16
New cards

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

17
New cards

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

18
New cards

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

19
New cards

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

20
New cards

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

21
New cards

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