Complete the code to define the server listening on port 80.
server {
listen [1];
}The listen directive tells Nginx which port to listen on. Port 80 is the default for HTTP.
Complete the code to route API requests to the backend server.
location /api/ {
proxy_pass [1];
}The proxy_pass directive forwards requests to the backend server. Here, the backend runs on localhost port 3000.
Fix the error in the proxy header to pass the original host.
location /api/ {
proxy_set_header Host [1];
}Using $host passes the original host header to the backend, which is important for routing and logging.
Complete the code to rewrite the API URL path correctly.
location /api/ {
proxy_pass http://backend[1]api;
}Adding a trailing slash / after the backend URL and no extra path after api ensures the path is rewritten correctly.
Fill all three blanks to add caching headers for API responses.
location /api/ {
proxy_pass http://backend/;
add_header Cache-Control [1];
add_header Pragma [2];
add_header Expires [3];
}Setting Cache-Control to "no-cache", Pragma to "no-store", and Expires to "0" disables caching for API responses.