Challenge - 5 Problems
Nginx Server Block Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of nginx -t with this server block?
Given this nginx server block configuration, what will be the output of
nginx -t?Nginx
server {
listen 80;
server_name example.com www.example.com;
root /var/www/example;
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
}Attempts:
2 left
💡 Hint
Check if the syntax of the server block is correct and all directives are valid.
✗ Incorrect
The server block syntax is correct with valid directives. The test command checks syntax only, not file existence, so it reports success.
🧠 Conceptual
intermediate1:00remaining
Which directive defines the domain names served by this server block?
In an nginx server block, which directive specifies the domain names that the server responds to?
Attempts:
2 left
💡 Hint
Think about which directive tells nginx which website names to match.
✗ Incorrect
The 'server_name' directive lists the domain names that the server block will respond to.
❓ Configuration
advanced2:00remaining
Identify the error in this server block configuration
What error will nginx report when testing this server block configuration?
Nginx
server {
listen 80
server_name example.com;
root /var/www/html;
}Attempts:
2 left
💡 Hint
Check for missing semicolons in the configuration.
✗ Incorrect
The 'listen 80' line is missing a semicolon at the end, causing a syntax error.
❓ Troubleshoot
advanced2:00remaining
Why does nginx serve the default site instead of your custom server block?
You created a server block for example.com but nginx serves the default site instead. What is the most likely cause?
Attempts:
2 left
💡 Hint
Check if nginx knows which server block matches the domain you requested.
✗ Incorrect
If server_name does not match the requested domain, nginx falls back to the default server block.
🔀 Workflow
expert3:00remaining
Order the steps to enable a new nginx server block and activate it
Put these steps in the correct order to enable a new nginx server block and make it active.
Attempts:
2 left
💡 Hint
Think about creating config, testing it, enabling it, then reloading nginx.
✗ Incorrect
First create the config file, then test syntax, then enable by linking, finally reload nginx.