Complete the code to define a basic location block for the root URL.
location [1] {
root /var/www/html;
}The root location block uses / to match the base URL path.
Complete the code to define a nested location block that matches URLs starting with /images/.
location / {
location [1] {
root /var/www/images;
}
}The nested location block should match /images/ to serve image files.
Fix the error in the nested location block to correctly match URLs ending with .php.
location /app/ {
location [1] {
fastcgi_pass unix:/var/run/php-fpm.sock;
}
}The ~ \.php$ syntax defines a case-sensitive regex to match URLs ending with .php.
Fill both blanks to create a nested location block that matches /api/ and proxies requests to a backend server.
location [1] { location [2] { proxy_pass http://backend_server; } }
The outer block matches /api/ and the inner nested block matches /v1/ for versioned API calls.
Fill all three blanks to define nested location blocks for /app/, /static/, and /images/ with appropriate root directories.
location [1] { location [2] { root /var/www/static; } location [3] { root /var/www/images; } }
The outer block matches /app/. Inside it, nested blocks match /static/ and /images/ with their respective root directories.