0
0
Nginxdevops~20 mins

Directory listing (autoindex) in Nginx - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Directory Listing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this nginx configuration snippet?
Given this nginx server block snippet, what will be the result when accessing the /files URL?
location /files {
    root /var/www/html;
    autoindex on;
}
AThe browser shows a 404 Not Found error because the root directive is incorrect.
BA plain text list of files and directories inside /var/www/html/files is shown in the browser.
CThe browser downloads the index.html file from /var/www/html/files automatically.
DThe browser shows a 403 Forbidden error because autoindex is off by default.
Attempts:
2 left
💡 Hint
autoindex on enables directory listing if no index file is found.
Configuration
intermediate
2:00remaining
Which configuration enables directory listing only for /public path?
Select the correct nginx configuration snippet that enables directory listing only for the /public URL path.
A
location /public {
    root /var/www/html;
    autoindex on;
}
B
location / {
    root /var/www/html/public;
    autoindex on;
}
C
location /public {
    root /var/www/html/public;
    autoindex off;
}
D
location /public {
    alias /var/www/html/public;
    autoindex off;
}
Attempts:
2 left
💡 Hint
autoindex must be on and root must point to the base directory.
Troubleshoot
advanced
2:00remaining
Why does directory listing not show despite autoindex on?
You set autoindex on in your nginx config for /data, but visiting /data shows a 403 Forbidden error. What is the most likely cause?
AThe index directive is set to a file that does not exist, causing 403.
BThe autoindex directive must be set inside the http block, not location.
CThe root directive is missing, so nginx cannot find the directory.
DThe directory /var/www/html/data lacks read permissions for the nginx user.
Attempts:
2 left
💡 Hint
Check file system permissions for nginx user.
Best Practice
advanced
2:00remaining
What is the safest way to enable directory listing for a public folder?
Choose the best practice to safely enable directory listing for /public folder in nginx.
AEnable autoindex on only for /public location and restrict access to other locations.
BUse autoindex on in /public and disable access logging to hide activity.
CEnable autoindex on globally in the http block for all locations.
DEnable autoindex on and disable all authentication to allow anonymous access.
Attempts:
2 left
💡 Hint
Limit directory listing to only needed paths.
🔀 Workflow
expert
3:00remaining
Order the steps to enable and verify directory listing in nginx
Put these steps in the correct order to enable directory listing for /files and verify it works.
A1,3,2,4
B1,2,3,4
C3,1,2,4
D3,2,1,4
Attempts:
2 left
💡 Hint
Check permissions before reloading nginx.