Quiz: Nginx & Web Servers¶
4 questions
L0 (1 questions)¶
1. Why must you always run 'nginx -t' before 'nginx -s reload'?
Show answer
nginx -t tests the configuration syntax without applying it. If the config has errors and you reload without testing, Nginx may fail to reload and in some cases the workers can crash, causing downtime. Testing first is a zero-cost safety check that prevents config errors from reaching production.L1 (1 questions)¶
1. Explain the proxy_pass trailing slash behavior: what is the difference between 'proxy_pass http://backend' and 'proxy_pass http://backend/'?
Show answer
Without trailing slash: the location path is appended to the backend URL. Request to /app/page proxies to backend/app/page. With trailing slash: the location path is replaced. Request to /app/page (in a 'location /app/' block) proxies to backend/page. This is a top-5 Nginx misconfiguration — getting it wrong sends mangled paths to the backend.L2 (1 questions)¶
1. Describe the Nginx location matching priority order. If you have 'location /api' and 'location ~ /api', which wins?
Show answer
Priority order:1. Exact match (=) — highest.
2. Prefix with ^~ — stops regex evaluation.
3. Regex (~ or ~*) — first match in config order wins.
4. Plain prefix — longest match, lowest priority. So 'location ~ /api' (regex) beats 'location /api' (plain prefix) because regex is evaluated after prefix matching and takes precedence unless the prefix uses ^~.
L3 (1 questions)¶
1. How do you configure Nginx upstream health checks and keepalive connections for a backend pool?