0
0
Nginxdevops~10 mins

Default server handling 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 default server in an Nginx listen directive.

Nginx
server {
    listen 80 [1];
    server_name example.com;
}
Drag options to blanks, or click blank then click option'
Aprimary
Bdefault
Cdefault_server
Dmain_server
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'default' instead of 'default_server' causes a syntax error.
Omitting the default_server means Nginx uses the first server block as default.
2fill in blank
medium

Complete the code to define a server block that listens on port 443 as the default server.

Nginx
server {
    listen [1] ssl default_server;
    server_name secure.example.com;
}
Drag options to blanks, or click blank then click option'
A443
B80
C8080
D8443
Attempts:
3 left
💡 Hint
Common Mistakes
Using port 80 for SSL causes connection errors.
Forgetting 'default_server' means this server won't be the default.
3fill in blank
hard

Fix the error in the listen directive to correctly set the default server on port 8080.

Nginx
server {
    listen 8080 [1];
    server_name app.example.com;
}
Drag options to blanks, or click blank then click option'
Adefault
Bmain
Cprimary_server
Ddefault_server
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'default' instead of 'default_server' causes Nginx to fail to start.
Omitting the default_server keyword means this server is not default.
4fill in blank
hard

Fill both blanks to create a server block that listens on port 80 and sets it as the default server.

Nginx
server {
    listen [1] [2];
    server_name default.example.com;
}
Drag options to blanks, or click blank then click option'
A80
Bdefault_server
Cssl
Dhttp2
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ssl' or 'http2' without 'default_server' does not set default.
Swapping the order of port and default_server causes syntax errors.
5fill in blank
hard

Fill all three blanks to create a server block that listens on port 443 with SSL and sets it as the default server.

Nginx
server {
    listen [1] [2] [3];
    server_name secure.default.com;
}
Drag options to blanks, or click blank then click option'
A443
Bssl
Cdefault_server
Dhttp2
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting 'ssl' causes HTTPS to fail.
Not including 'default_server' means this is not the default server.
Using 'http2' instead of 'ssl' is incorrect for SSL setup.