Recall & Review
beginner
What is a named location in nginx and how is it defined?
A named location in nginx is a special internal location block identified by an '@' prefix. It is defined using
location @name { ... } and is used for internal redirects within the server configuration.Click to reveal answer
beginner
How do you perform an internal redirect to a named location in nginx?
You use the
try_files directive or the error_page directive with a URI starting with '@'. For example, try_files $uri @fallback; redirects internally to the named location @fallback if the file is not found.Click to reveal answer
intermediate
Why would you use named locations in nginx instead of regular locations?
Named locations are used for internal redirects only and are not accessible directly by clients. They help organize complex routing logic, such as fallback handling or error processing, without exposing these paths externally.
Click to reveal answer
beginner
Can a named location be accessed directly by a client request?
No, named locations cannot be accessed directly by clients. They are internal and only reachable through internal redirects configured in nginx.
Click to reveal answer
intermediate
Show an example of a named location used for fallback in nginx.
Example:<br>
location / {
try_files $uri $uri/ @fallback;
}
location @fallback {
proxy_pass http://backend;
}<br>This tries to serve the file, and if not found, internally redirects to @fallback which proxies the request.Click to reveal answer
What prefix is used to define a named location in nginx?
✗ Incorrect
Named locations in nginx always start with the '@' symbol.
Can clients directly access a named location URL in nginx?
✗ Incorrect
Named locations are internal and cannot be accessed directly by clients.
Which directive is commonly used to redirect to a named location if a file is not found?
✗ Incorrect
The try_files directive can redirect internally to a named location if files are missing.
What is the main purpose of using named locations in nginx?
✗ Incorrect
Named locations help organize internal redirects for routing and fallback logic.
Which of the following is a valid named location block in nginx?
✗ Incorrect
Named locations are defined with 'location @name { }' syntax.
Explain what named locations (@) are in nginx and why they are useful.
Think about how nginx handles internal routing and fallback.
You got /5 concepts.
Describe how to configure nginx to use a named location for fallback when a requested file is missing.
Focus on the try_files syntax and named location block.
You got /4 concepts.