0
0
Nginxdevops~5 mins

Root directive in Nginx - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the root directive do in an nginx configuration?
The root directive sets the directory path where nginx looks for files to serve for a given location or server block.
Click to reveal answer
beginner
Where can the root directive be used in nginx configuration?
It can be used inside the http, server, or location blocks to specify the root directory for serving files.
Click to reveal answer
intermediate
How does nginx combine the root directive path with the request URI?
Nginx appends the request URI to the path set by the root directive to find the file to serve.
Click to reveal answer
intermediate
What happens if the root directive is set in both server and location blocks?
The root directive in the location block overrides the one in the server block for that location.
Click to reveal answer
beginner
Example: How to set the root directory to /var/www/html for a server in nginx?
Inside the server block, add: <br>
root /var/www/html;
Click to reveal answer
What does the nginx root directive specify?
AThe directory where nginx looks for files to serve
BThe IP address of the server
CThe port number nginx listens on
DThe logging level for nginx
If root is set in both server and location blocks, which one is used for that location?
AThe one in the <code>server</code> block
BThe one in the <code>location</code> block
CBoth are combined
DNginx throws an error
How does nginx find the file to serve when a request comes in?
AIt only uses the request URI
BIt uses the <code>root</code> path only
CIt uses the <code>root</code> path plus the request URI
DIt randomly selects a file
Where can the root directive NOT be used?
AInside <code>http</code> block
BInside <code>server</code> block
CInside <code>location</code> block
DInside <code>events</code> block
What is the correct syntax to set the root directory to /usr/share/nginx/html?
Aroot /usr/share/nginx/html;
Bset root /usr/share/nginx/html;
Croot = /usr/share/nginx/html;
Droot: /usr/share/nginx/html;
Explain how the nginx root directive works and where it can be used.
Think about how nginx finds files to serve for web requests.
You got /3 concepts.
    Describe what happens when root is set in both server and location blocks in nginx.
    Consider configuration precedence in nginx.
    You got /3 concepts.