Challenge - 5 Problems
API Versioning Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of NGINX routing for API version v1
Given the following NGINX configuration snippet, what will be the response status code when a client requests
/api/v1/users?Nginx
server {
listen 80;
location /api/v1/ {
proxy_pass http://backend_v1/;
}
location /api/v2/ {
proxy_pass http://backend_v2/;
}
}Attempts:
2 left
💡 Hint
Check which location block matches the requested URI.
✗ Incorrect
The request URI /api/v1/users matches the location /api/v1/ which proxies to backend_v1. Assuming backend_v1 is healthy, the response is 200 OK.
❓ Configuration
intermediate2:00remaining
Correct NGINX config for API versioning with header
Which NGINX configuration snippet correctly routes requests to different backends based on the custom header
X-API-Version with values v1 or v2?Attempts:
2 left
💡 Hint
Use the
map directive to select backend based on header.✗ Incorrect
Option B uses the
map directive to assign the backend based on the X-API-Version header, then proxies accordingly. Other options misuse if or location blocks.❓ Troubleshoot
advanced2:00remaining
Troubleshoot NGINX API version routing failure
A user reports that requests to
/api/v2/orders always return 404 Not Found, but /api/v1/orders works fine. Given this NGINX config, what is the most likely cause?Nginx
server {
listen 80;
location /api/v1/ {
proxy_pass http://backend_v1/;
}
location /api/v2 {
proxy_pass http://backend_v2/;
}
}Attempts:
2 left
💡 Hint
Check how NGINX matches location blocks and rewrites URIs with proxy_pass.
✗ Incorrect
The location /api/v2 lacks a trailing slash, so NGINX does not rewrite the URI correctly, causing 404 errors. Adding a trailing slash fixes the issue.
🔀 Workflow
advanced2:00remaining
Order of NGINX location blocks for API versioning
Given these location blocks, what is the correct order to ensure requests to
/api/v2/users route to the v2 backend and /api/users route to the default backend?Attempts:
2 left
💡 Hint
More specific location blocks must come before less specific ones.
✗ Incorrect
NGINX matches location blocks in order of specificity. The most specific (/api/v2/) must come first, then /api/v1/, then the general /api/.
✅ Best Practice
expert3:00remaining
Best practice for API versioning in NGINX with minimal config duplication
Which NGINX configuration approach best minimizes duplication while supporting multiple API versions with shared common settings?
Attempts:
2 left
💡 Hint
Think about how to reuse proxy settings and avoid repeating code.
✗ Incorrect
Using
map to select backend based on header allows one location block with shared proxy settings, reducing duplication and easing maintenance.