Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a named location called @maintenance.
Nginx
location [1] { return 503; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a slash '/' instead of '@' for named locations.
Using '#' or '~' which are not valid for named locations.
✗ Incorrect
Named locations in nginx start with an '@' symbol followed by the name. Here, '@maintenance' defines the named location.
2fill in blank
mediumComplete the code to redirect requests to the named location @fallback.
Nginx
location / {
try_files $uri $uri/ [1];
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Adding 'redirect' or 'rewrite' keywords inside try_files.
Forgetting the '@' symbol before the location name.
✗ Incorrect
In try_files, to redirect to a named location, just specify the name starting with '@'.
3fill in blank
hardFix the error in the named location definition to properly return a 404 status.
Nginx
location [1] { return 404; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting '@' in the named location name.
Using slashes or regex symbols in named location names.
✗ Incorrect
Named locations must start with '@'. Without '@', nginx treats it as a normal location and may cause errors.
4fill in blank
hardFill both blanks to define a named location @error and redirect to it from /error.
Nginx
location /error {
error_page 500 502 503 504 [1];
}
location [2] {
return 500;
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names for error_page and location.
Omitting '@' in named location names.
✗ Incorrect
The error_page directive should point to the named location '@error', and the named location is defined as '@error'.
5fill in blank
hardFill all three blanks to create a named location @maintenance, redirect to it from /, and return 503 inside it.
Nginx
location / {
try_files $uri $uri/ [1];
}
location [2] {
return [3];
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names for the named location in try_files and location.
Returning wrong HTTP status code inside the named location.
✗ Incorrect
The try_files directive redirects to '@maintenance', the named location is '@maintenance', and it returns status 503.