Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to enable basic authentication in the server block.
Nginx
server {
listen 80;
location / {
auth_basic [1];
auth_basic_user_file /etc/nginx/.htpasswd;
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using off disables authentication instead of enabling it.
Not using quotes around the realm string causes syntax errors.
✗ Incorrect
The auth_basic directive requires a string to display as the authentication realm. "Restricted Area" is a common example.
2fill in blank
mediumComplete the code to specify the path to the password file for basic authentication.
Nginx
location /secure {
auth_basic "Secure Area";
auth_basic_user_file [1];
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the system's /etc/passwd file instead of the .htpasswd file.
Pointing to a directory or unrelated file causes errors.
✗ Incorrect
The auth_basic_user_file directive points to the password file, usually /etc/nginx/.htpasswd.
3fill in blank
hardFix the error in the auth_basic directive to enable basic authentication.
Nginx
location /admin {
auth_basic [1];
auth_basic_user_file /etc/nginx/.htpasswd;
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using off disables authentication.
Using unquoted strings causes syntax errors.
✗ Incorrect
The auth_basic directive must have a quoted string to enable authentication. "Admin Area" is correct.
4fill in blank
hardFill both blanks to configure basic authentication with a custom realm and password file.
Nginx
location /private {
auth_basic [1];
auth_basic_user_file [2];
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using an incorrect path for the password file.
Not quoting the realm string.
✗ Incorrect
The auth_basic directive needs a quoted realm string, and auth_basic_user_file needs the correct path to the password file.
5fill in blank
hardFill all three blanks to create a server block that listens on port 8080 and uses basic authentication with a custom realm and password file.
Nginx
server {
listen [1];
location /secure {
auth_basic [2];
auth_basic_user_file [3];
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the default port 80 instead of 8080.
Not quoting the realm string.
Incorrect password file path.
✗ Incorrect
The server listens on port 8080, the auth_basic directive uses a quoted realm string, and the password file path is correct.