0
0
Nginxdevops~20 mins

Configuration testing (nginx -t) - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Nginx Configuration 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 nginx -t with a valid configuration?
You run nginx -t after editing the configuration file and it is valid. What output do you expect?
A
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
B
nginx: [emerg] unknown directive "bad_directive" in /etc/nginx/nginx.conf:10
nginx: configuration file /etc/nginx/nginx.conf test failed
C
nginx: [warn] deprecated syntax in /etc/nginx/nginx.conf:5
nginx: configuration file /etc/nginx/nginx.conf test failed
Dbash: nginx: command not found
Attempts:
2 left
💡 Hint
Think about what nginx -t reports when the config is correct.
💻 Command Output
intermediate
2:00remaining
What error does nginx -t show for a missing semicolon?
You forgot a semicolon at the end of a directive in /etc/nginx/nginx.conf. What error message will nginx -t display?
A
nginx: [error] invalid directive in /etc/nginx/nginx.conf:15
nginx: configuration file /etc/nginx/nginx.conf test failed
B
nginx: [emerg] unexpected end of file, expecting ";" or "}" in /etc/nginx/nginx.conf:15
nginx: configuration file /etc/nginx/nginx.conf test failed
C
nginx: configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
D
nginx: [warn] missing semicolon in /etc/nginx/nginx.conf:15
nginx: configuration file /etc/nginx/nginx.conf test is successful
Attempts:
2 left
💡 Hint
Look for an error mentioning missing semicolon or unexpected end of file.
Troubleshoot
advanced
2:30remaining
Why does nginx -t fail with 'unknown directive' error?
You added a new directive bad_directive in your nginx config and ran nginx -t. It failed with an 'unknown directive' error. What is the most likely cause?
AThe directive name is misspelled or not supported by the installed nginx version.
BThe server block is missing a closing brace.
CThe configuration file has incorrect file permissions.
DThe nginx service is not running, so the test cannot complete.
Attempts:
2 left
💡 Hint
Think about what 'unknown directive' means in nginx config context.
Best Practice
advanced
2:00remaining
What is the best practice before reloading nginx after config changes?
You edited the nginx configuration file. What should you do before running systemctl reload nginx to avoid downtime?
ADelete the old configuration file to avoid conflicts.
BRestart the server to apply changes safely.
CRun <code>nginx -t</code> to test the configuration syntax for errors.
DRun <code>systemctl stop nginx</code> before reloading.
Attempts:
2 left
💡 Hint
Think about how to check config correctness without stopping the service.
🔀 Workflow
expert
3:00remaining
Order the steps to safely update nginx configuration with zero downtime
Arrange the following steps in the correct order to update nginx configuration safely without downtime.
A1,2,4,3
B2,1,3,4
C1,3,2,4
D1,2,3,4
Attempts:
2 left
💡 Hint
Remember to test config before reloading, and verify service after reload.