Challenge - 5 Problems
nginx.conf Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this nginx configuration test command?
You have an nginx configuration file with a syntax error. You run the command
nginx -t to test the configuration. What output will you see?Nginx
nginx: [emerg] unknown directive "serve_static" in /etc/nginx/nginx.conf:12 nginx: configuration file /etc/nginx/nginx.conf test failed
Attempts:
2 left
💡 Hint
Look for the exact error message when nginx finds an unknown directive.
✗ Incorrect
When nginx encounters an unknown directive in the configuration file, it reports an emergency level error with the line number and states that the configuration test failed.
🧠 Conceptual
intermediate1:30remaining
Which directive in nginx.conf sets the maximum number of worker processes?
In the main nginx configuration file, which directive controls how many worker processes nginx will start to handle requests?
Attempts:
2 left
💡 Hint
Think about the directive that defines how many separate workers run.
✗ Incorrect
The
worker_processes directive sets the number of worker processes nginx will spawn. Each worker handles connections.❓ Configuration
advanced2:30remaining
Identify the error in this nginx.conf snippet
Look at this snippet from an nginx.conf file. What is the error that will cause nginx to fail to start?
Nginx
http {
server {
listen 80;
server_name example.com;
location / {
root /var/www/html;
index index.html index.htm;
}
}
worker_processes 4;
}Attempts:
2 left
💡 Hint
Check where 'worker_processes' is allowed in nginx.conf.
✗ Incorrect
The 'worker_processes' directive must be in the main context, not inside 'http' or 'server' blocks. Placing it inside 'http' causes a configuration error.
❓ Troubleshoot
advanced2:00remaining
Why does nginx fail to reload with this configuration?
You updated nginx.conf and ran
nginx -s reload. The reload failed with this error: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use). What is the most likely cause?Attempts:
2 left
💡 Hint
The error says 'Address already in use'. What does that mean?
✗ Incorrect
The error means some other process is already listening on port 80, so nginx cannot bind to it again. This is often caused by another web server or an existing nginx instance.
🔀 Workflow
expert3:00remaining
Order the steps to safely update nginx.conf and reload nginx without downtime
Put these steps in the correct order to update nginx configuration safely and reload nginx without downtime.
Attempts:
2 left
💡 Hint
Think about protecting the current config before editing and verifying before reloading.
✗ Incorrect
First backup the current config to restore if needed. Then edit the file. Next test syntax to catch errors. Finally reload nginx to apply changes without downtime.