Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
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.
✗ Incorrect
The 'default_server' parameter in the listen directive marks this server block as the default for requests on that port.
2fill in blank
mediumComplete 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'
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.
✗ Incorrect
Port 443 is the standard port for HTTPS, so the default server for SSL listens on 443.
3fill in blank
hardFix 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'
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.
✗ Incorrect
The correct keyword to set a default server is 'default_server'. 'default' is invalid and causes an error.
4fill in blank
hardFill 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'
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.
✗ Incorrect
The listen directive needs the port number '80' and the 'default_server' keyword to mark it as default.
5fill in blank
hardFill 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'
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.
✗ Incorrect
The listen directive requires port '443', 'ssl' for HTTPS, and 'default_server' to mark it as default.