0
0
Nginxdevops~10 mins

Server block structure 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 start a basic server block listening on port 80.

Nginx
server {
    listen [1];
}
Drag options to blanks, or click blank then click option'
A80
B443
C22
D8080
Attempts:
3 left
💡 Hint
Common Mistakes
Using port 443 which is for HTTPS instead of 80.
Using port 22 which is for SSH.
2fill in blank
medium

Complete the code to set the server name to example.com.

Nginx
server {
    server_name [1];
}
Drag options to blanks, or click blank then click option'
Alocalhost
Bdefault
Cmyserver
Dexample.com
Attempts:
3 left
💡 Hint
Common Mistakes
Using localhost which is for local testing.
Using generic names like default which won't match the domain.
3fill in blank
hard

Fix the error in the server block to correctly serve files from /var/www/html.

Nginx
server {
    root [1];
}
Drag options to blanks, or click blank then click option'
A/home/user/html
B/etc/nginx/html
C/var/www/html
D/usr/share/nginx/html
Attempts:
3 left
💡 Hint
Common Mistakes
Using /usr/share/nginx/html which is default for some distros but not the target here.
Using home directories which are not accessible by nginx.
4fill in blank
hard

Fill both blanks to configure the server block to listen on port 443 and enable SSL.

Nginx
server {
    listen [1] ssl;
    ssl_certificate [2];
}
Drag options to blanks, or click blank then click option'
A443
B/etc/ssl/certs/server.crt
C/etc/nginx/ssl/server.key
D80
Attempts:
3 left
💡 Hint
Common Mistakes
Using port 80 which is for HTTP, not HTTPS.
Confusing certificate and key file paths.
5fill in blank
hard

Fill all three blanks to create a server block that listens on port 80, sets server_name to mysite.com, and serves files from /srv/mysite.

Nginx
server {
    listen [1];
    server_name [2];
    root [3];
}
Drag options to blanks, or click blank then click option'
A443
Bmysite.com
C/srv/mysite
D80
Attempts:
3 left
💡 Hint
Common Mistakes
Using port 443 for HTTP instead of 80.
Setting server_name to localhost or default.
Using wrong root directory paths.