But requests to /home are always sent to http://frontend. What is the likely problem?
medium
A. The exact match location block is not matched because of a syntax error.
B. The exact match location block is missing a trailing slash.
C. The exact match location is overridden by prefix match due to order.
D. The exact match location block is ignored because proxy_pass is invalid.
Solution
Step 1: Check syntax of exact match location
The exact match location location = /home { ... } may have a syntax error like missing semicolon after proxy_pass, causing nginx to ignore it.
Step 2: Consider nginx matching rules
Exact match locations have highest priority and should be matched first. If requests go to frontend, likely the exact match block is ignored due to a syntax error or config reload issue.
Step 3: Identify common mistake
Often, missing semicolons or incorrect proxy_pass URL cause nginx to ignore the block silently.
Final Answer:
The exact match location block is not matched because of a syntax error. -> Option A
Quick Check:
Syntax errors cause nginx to ignore blocks [OK]
Hint: Check syntax errors if exact match ignored [OK]
Common Mistakes:
Assuming order affects exact match priority
Missing semicolon after proxy_pass
Confusing trailing slash importance
5. You want to serve a special static page only when the URL is exactly /special. Which nginx config snippet correctly achieves this without affecting other URLs starting with /special?
hard
A. location /special { root /var/www/special; }
B. location ~ /special { root /var/www/special; }
C. location = /special { root /var/www/special; }
D. location ^~ /special { root /var/www/special; }
Solution
Step 1: Understand exact match requirement
To serve only the exact URL /special, use location = /special which matches exactly that path.
Step 2: Analyze other options
location /special { root /var/www/special; } matches any URL starting with /special. location ~ /special { root /var/www/special; } uses regex to match URLs containing /special anywhere. location ^~ /special { root /var/www/special; } uses prefix match with ^~, which matches prefixes but not exact only.
Final Answer:
location = /special { root /var/www/special; } -> Option C
Quick Check:
Exact match = location = /path [OK]
Hint: Use = for exact URL, not prefix or regex [OK]