0
0
Nginxdevops~10 mins

Directives and blocks 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 server listening port to 8080.

Nginx
server {
    listen [1];
}
Drag options to blanks, or click blank then click option'
A3000
B8080
C443
D80
Attempts:
3 left
💡 Hint
Common Mistakes
Using port 80 instead of 8080
Putting the port in quotes
2fill in blank
medium

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

Nginx
server {
    root [1];
}
Drag options to blanks, or click blank then click option'
A/etc/nginx
B/usr/local/bin
C/var/www/html
D/home/user
Attempts:
3 left
💡 Hint
Common Mistakes
Using system config directories like /etc/nginx
Using user home directories
3fill in blank
hard

Fix the error in the location block to serve static files from /static.

Nginx
server {
    location /static/ [1]
        root /var/www/html;
    }
}
Drag options to blanks, or click blank then click option'
A<
B(
C[
D{
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses or brackets instead of curly braces
Missing the opening brace
4fill in blank
hard

Complete the code to create a server block that listens on port 80 and serves files from /usr/share/nginx/html.

Nginx
server {
    listen [1];
    root /usr/share/nginx/html;
}
Drag options to blanks, or click blank then click option'
A{
B8080
C80
D(
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong brace types
Setting listen to wrong port
5fill in blank
hard

Complete the code to create a location block that matches /images/, uses alias to /data/images, and closes the block properly.

Nginx
location /images/ {
    alias [1];
}
Drag options to blanks, or click blank then click option'
A{
B/data/images
C}
D(
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses instead of braces
Forgetting to close the block
Using root instead of alias