0
0
Nginxdevops~10 mins

Root directive in Nginx - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the root directory for the server.

Nginx
server {
    listen 80;
    [1] /var/www/html;
}
Drag options to blanks, or click blank then click option'
Aroot
Blocation
Cserver_name
Dindex
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'location' instead of 'root' to set the directory.
Confusing 'index' with 'root'.
2fill in blank
medium

Complete the code to set the root directory inside a location block.

Nginx
server {
    listen 80;
    location /images/ {
        [1] /data/images;
    }
}
Drag options to blanks, or click blank then click option'
Aindex
Broot
Calias
Dproxy_pass
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'alias' instead of 'root' inside location block incorrectly.
Using 'proxy_pass' which is for proxying requests.
3fill in blank
hard

Fix the error in the root directive syntax.

Nginx
server {
    listen 80;
    root [1] /var/www/html;
}
Drag options to blanks, or click blank then click option'
A/var/www/html
B;
C/var/www/html;
D(none)
Attempts:
3 left
💡 Hint
Common Mistakes
Adding an extra token between 'root' and the path.
Missing the semicolon at the end.
4fill in blank
hard

Fill both blanks to create a location block that serves files from /usr/share/nginx/html for the root URL.

Nginx
server {
    listen 80;
    location [1] {
        [2] /usr/share/nginx/html;
    }
}
Drag options to blanks, or click blank then click option'
A/
Broot
C/images/
Dalias
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'alias' instead of 'root' inside the location block.
Using a wrong location path like '/images/' for the root URL.
5fill in blank
hard

Fill all three blanks to create a server block that listens on port 8080, serves files from /var/www/site, and sets the index file to index.html.

Nginx
server {
    listen [1];
    root [2];
    index [3];
}
Drag options to blanks, or click blank then click option'
A80
B/var/www/site
Cindex.html
D8080
Attempts:
3 left
💡 Hint
Common Mistakes
Using port 80 instead of 8080.
Confusing 'index' and 'root' directives.
Missing semicolons at the end of directives.