0
0
Nginxdevops~10 mins

Named locations (@) in Nginx - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a named location called @maintenance.

Nginx
location [1] {
    return 503;
}
Drag options to blanks, or click blank then click option'
A#maintenance
B/maintenance
C@maintenance
D~maintenance
Attempts:
3 left
💡 Hint
Common Mistakes
Using a slash '/' instead of '@' for named locations.
Using '#' or '~' which are not valid for named locations.
2fill in blank
medium

Complete 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'
Aproxy_pass @fallback
Bredirect @fallback
Crewrite @fallback
D@fallback
Attempts:
3 left
💡 Hint
Common Mistakes
Adding 'redirect' or 'rewrite' keywords inside try_files.
Forgetting the '@' symbol before the location name.
3fill in blank
hard

Fix 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'
A/not_found
B@not_found
Cnot_found
D~not_found
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting '@' in the named location name.
Using slashes or regex symbols in named location names.
4fill in blank
hard

Fill 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'
A@error
B/error
C@fail
D/fail
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names for error_page and location.
Omitting '@' in named location names.
5fill in blank
hard

Fill 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'
A@maintenance
B503
C@down
D404
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.