Recall & Review
beginner
What is the purpose of the
index directive in nginx?The
index directive tells nginx which file to serve when a directory is requested. It looks for the specified files in order and serves the first one it finds.Click to reveal answer
beginner
How does nginx behave if the
index directive is not set and a directory is requested?If the
index directive is not set, nginx uses the default value index.html and attempts to serve that file for a directory request. If the file does not exist, it may return a 403 Forbidden error or list the directory contents if autoindex is enabled.Click to reveal answer
beginner
Example: <br>
index index.html index.htm; <br> What does this configuration mean?This means nginx will first look for a file named
index.html in the requested directory. If it is not found, it will look for index.htm. It serves the first file found.Click to reveal answer
intermediate
Can the
index directive accept multiple file names? How does nginx use them?Yes, the
index directive can list multiple file names separated by spaces. Nginx checks them in order and serves the first existing file it finds in the directory.Click to reveal answer
intermediate
Where in the nginx configuration file can the
index directive be placed?The
index directive can be placed inside the http, server, or location blocks to control default files at different levels.Click to reveal answer
What does the nginx
index directive do?✗ Incorrect
The
index directive tells nginx which file to serve by default when a directory URL is requested.If
index index.html index.htm; is set, and both files exist, which one will nginx serve?✗ Incorrect
Nginx serves the first file listed in the
index directive that exists. Here, index.html is first.Where can the
index directive be used in nginx configuration?✗ Incorrect
The
index directive can be placed in http, server, or location blocks to control default files at different levels.What happens if no file listed in the
index directive exists in the directory?✗ Incorrect
If no index file is found, nginx may list directory contents if autoindex is enabled; otherwise, it may return an error.
Can the
index directive accept only one file name?✗ Incorrect
The
index directive can accept one or multiple file names to check in order.Explain how the nginx
index directive works when a user requests a directory URL.Think about what nginx does when you visit a folder on a website.
You got /4 concepts.
Describe where you can place the
index directive in nginx configuration and why placement matters.Consider different levels of configuration in nginx.
You got /4 concepts.