Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to disable logging for requests with status 404.
Nginx
map $status $loggable {
404 [1];
default 1;
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'off' or 'disable' instead of 0 disables logging incorrectly.
Setting 404 to 1 will enable logging instead of disabling it.
✗ Incorrect
Setting the value to 0 disables logging for status 404.
2fill in blank
mediumComplete the code to use the variable $loggable to control access log.
Nginx
access_log /var/log/nginx/access.log combined if=[1];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using $status directly in the 'if' condition does not work as expected.
Using unrelated variables like $request_method or $remote_addr.
✗ Incorrect
The 'if' parameter uses the $loggable variable to conditionally enable logging.
3fill in blank
hardFix the error in the map block to correctly disable logging for 500 errors.
Nginx
map $status $loggable {
500 [1];
default 1;
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'off' or 'disable' causes configuration errors.
Using 'false' is not recognized by nginx in map.
✗ Incorrect
Only 0 disables logging correctly in the map block; 'off', 'disable', or 'false' are invalid.
4fill in blank
hardFill both blanks to log only POST requests with status 200.
Nginx
map "$request_method:$status" $loggable { "[1]:[2]" 1; default 0; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'GET' instead of 'POST' will log wrong requests.
Using '404' instead of '200' will log wrong status.
✗ Incorrect
The map matches 'POST:200' to enable logging only for POST requests with status 200.
5fill in blank
hardFill all three blanks to log requests from 192.168.1.1 with status 403 or 404.
Nginx
map "$remote_addr:$status" $loggable { "[1]:[2]" 1; "[1]:[3]" 1; default 0; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different IPs for the two entries.
Using status 200 instead of 403 or 404.
✗ Incorrect
The map enables logging for IP 192.168.1.1 with status 403 or 404 only.