Complete the code to define a location block for the API path.
location [1] {
proxy_pass http://backend_api;
}The location block should match the API path /api to route requests correctly.
Complete the code to proxy API requests to the backend server.
location /api {
proxy_pass [1];
}The proxy_pass should point to the backend API server to forward API requests.
Fix the error in the location block to correctly match all API requests including subpaths.
location [1] {
proxy_pass http://backend_api;
}Using /api/ ensures that all requests starting with /api/ including subpaths are matched.
Fill both blanks to rewrite the URL path before proxying to backend.
location /api/ {
proxy_pass http://backend_api[1];
rewrite [2] $1 break;
}The proxy_pass appends /v1 to the backend URL. The rewrite uses regex to capture the path after /api/.
Fill all three blanks to create a location block that proxies /api requests to backend and sets a custom header.
location [1] { proxy_pass [2]; proxy_set_header [3] "API-Request"; }
The location block matches /api/, proxies to backend_api, and sets a custom header X-Custom-Header with value API-Request.