0
0
Nginxdevops~20 mins

Main configuration file (nginx.conf) - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
nginx.conf Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2: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
Anginx: configuration file /etc/nginx/nginx.conf syntax is ok\nnginx: configuration file /etc/nginx/nginx.conf test is successful
Bnginx: [emerg] unknown directive "serve_static" in /etc/nginx/nginx.conf:12\nnginx: configuration file /etc/nginx/nginx.conf test failed
Cnginx: [warn] deprecated directive used in /etc/nginx/nginx.conf:12\nnginx: configuration file /etc/nginx/nginx.conf test failed
Dnginx: error: could not open configuration file /etc/nginx/nginx.conf
Attempts:
2 left
💡 Hint
Look for the exact error message when nginx finds an unknown directive.
🧠 Conceptual
intermediate
1: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?
Aworker_processes
Bworker_connections
Cmax_clients
Dprocess_limit
Attempts:
2 left
💡 Hint
Think about the directive that defines how many separate workers run.
Configuration
advanced
2: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;
}
AThe directive 'worker_processes' is inside the 'http' block, which is invalid.
BThe 'root' directive must be inside the 'server' block, not 'location'.
CThe 'listen' directive must be outside the 'server' block.
DThe 'index' directive cannot have multiple files listed.
Attempts:
2 left
💡 Hint
Check where 'worker_processes' is allowed in nginx.conf.
Troubleshoot
advanced
2: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?
AThe firewall is blocking port 80.
BThe nginx user does not have permission to bind to port 80.
CThe configuration file has a syntax error on the listen directive.
DAnother process is already using port 80, so nginx cannot bind to it.
Attempts:
2 left
💡 Hint
The error says 'Address already in use'. What does that mean?
🔀 Workflow
expert
3: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.
A4,2,1,3
B1,4,2,3
C4,1,2,3
D2,4,1,3
Attempts:
2 left
💡 Hint
Think about protecting the current config before editing and verifying before reloading.