Hint: root sets base path; autoindex shows directory listing [OK]
Common Mistakes:
Confusing root with alias
Assuming redirect happens automatically
Ignoring autoindex effect
4. Identify the error in this nginx configuration snippet:
server {
listen 80
server_name example.com;
}
medium
A. listen directive should be inside location block.
B. server_name directive cannot be inside server block.
C. Missing semicolon after listen 80 directive.
D. Curly braces are missing around listen directive.
Solution
Step 1: Check syntax of directives
Each directive must end with a semicolon in nginx configuration.
Step 2: Locate missing semicolon
The listen 80 directive is missing a semicolon at the end.
Final Answer:
Missing semicolon after listen 80 directive. -> Option C
Quick Check:
Every directive ends with ; [OK]
Hint: Check every directive ends with ; [OK]
Common Mistakes:
Forgetting semicolon at directive end
Misplacing directives outside server block
Adding unnecessary braces
5. You want to configure nginx to serve static files from /var/www/html for all requests under /static/. Which configuration block correctly achieves this?
hard
A. location /static/ {
alias /var/www/html/;
}
B. location /static {
alias /var/www/html;
}
C. location /static/ {
root /var/www/html;
}
D. location /static/ {
root /var/www/html/;
}
Solution
Step 1: Understand root vs alias
Root appends the request URI to the root path; alias replaces the location prefix with the alias path.
Step 2: Match location and alias usage
For prefix locations ending with /, alias must end with / to correctly map paths.
Step 3: Evaluate options
location /static/ {
alias /var/www/html/;
} uses location /static/ { alias /var/www/html/; } which correctly serves files under /static/ from /var/www/html.
Final Answer:
location /static/ {
alias /var/www/html/;
} -> Option A
Quick Check:
Use alias with trailing slash for prefix location [OK]
Hint: Use alias with trailing slash for prefix locations [OK]
Common Mistakes:
Using root instead of alias for prefix paths
Missing trailing slash on alias path
Mismatching location and alias slashes
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.