0
0
Nginxdevops~20 mins

Exact match (=) in Nginx - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Exact Match Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the effect of the exact match (=) in this nginx location block?
Consider this nginx configuration snippet:
location = /about {
    return 200 'Exact match page';
}

What happens when a client requests /about?
Nginx
location = /about {
    return 200 'Exact match page';
}
AThe server returns 'Exact match page' for any URI starting with '/about'.
BThe server returns 'Exact match page' for any URI containing '/about' anywhere.
CThe server returns 'Exact match page' for any URI ending with '/about'.
DThe server returns 'Exact match page' only if the request URI is exactly '/about'.
Attempts:
2 left
💡 Hint
The '=' sign means the location matches the URI exactly, no more, no less.
🧠 Conceptual
intermediate
2:00remaining
How does nginx prioritize exact match (=) locations compared to prefix matches?
Given these location blocks:
location = /test {
    return 200 'Exact';
}
location /test {
    return 200 'Prefix';
}

Which location block will nginx use for a request to /test?
Nginx
location = /test {
    return 200 'Exact';
}
location /test {
    return 200 'Prefix';
}
Anginx uses the exact match location (= /test) before the prefix match (/test).
Bnginx uses the prefix match (/test) before the exact match (= /test).
Cnginx merges both locations and returns both responses.
Dnginx returns a 404 error because of conflicting locations.
Attempts:
2 left
💡 Hint
Exact match locations have the highest priority in nginx.
Troubleshoot
advanced
2:00remaining
Why does this nginx config not serve the exact match location as expected?
You have this config:
location = /home {
    proxy_pass http://backend1;
}
location /home {
    proxy_pass http://backend2;
}

Requests to /home are always served by backend2. Why?
Nginx
location = /home {
    proxy_pass http://backend1;
}
location /home {
    proxy_pass http://backend2;
}
AThe request URI includes a trailing slash, so it does not exactly match '/home'.
BThe exact match location is ignored because proxy_pass is missing a trailing slash.
Cnginx does not support exact match locations with proxy_pass directives.
DThe exact match location is overridden by the prefix location because of order in the config file.
Attempts:
2 left
💡 Hint
Check if the request URI exactly matches the location string, including trailing slashes.
Best Practice
advanced
2:00remaining
What is the recommended use of exact match (=) locations in nginx?
Which of these is the best practice when using exact match (=) locations in nginx?
AAvoid exact match locations because they cause nginx to reload the config on every request.
BUse exact match locations for specific URIs that need unique handling, like redirects or special responses.
CUse exact match locations for all static files to improve performance.
DUse exact match locations to match all URIs starting with a prefix.
Attempts:
2 left
💡 Hint
Exact match locations are precise and should be used sparingly for special cases.
🔀 Workflow
expert
3:00remaining
Order the steps nginx follows to select a location block for a request URI
Arrange the steps nginx uses to find the correct location block for a request URI, considering exact match (=), prefix, and regex locations.
A1,3,2,4
B2,1,3,4
C1,2,3,4
D3,1,2,4
Attempts:
2 left
💡 Hint
Exact matches have highest priority, then prefix, then regex.