0
0
Nginxdevops~20 mins

Separate config files per site in Nginx - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Nginx Config Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of nginx -t with separate site configs
You have two separate site config files in /etc/nginx/sites-available/ enabled via symlinks in /etc/nginx/sites-enabled/. What is the output of nginx -t if both configs are syntactically correct?
A
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Bnginx: [warn] conflicting server name in /etc/nginx/sites-enabled/site2.conf:15
Cnginx: [emerg] duplicate server name "example.com" in /etc/nginx/sites-enabled/site1.conf:10
Dnginx: [error] failed to open configuration file /etc/nginx/sites-enabled/site1.conf
Attempts:
2 left
💡 Hint
If configs are correct and enabled properly, nginx -t reports syntax ok and test successful.
Configuration
intermediate
2:00remaining
Correct way to enable a site config in nginx
Which command correctly enables a site config file named mysite.conf located in /etc/nginx/sites-available/ by creating a symlink in /etc/nginx/sites-enabled/?
Acp /etc/nginx/sites-available/mysite.conf /etc/nginx/sites-enabled/mysite.conf
Bmv /etc/nginx/sites-available/mysite.conf /etc/nginx/sites-enabled/
Cln -s /etc/nginx/sites-available/mysite.conf /etc/nginx/sites-enabled/mysite.conf
Drm /etc/nginx/sites-enabled/mysite.conf
Attempts:
2 left
💡 Hint
Enabling a site means linking the config, not copying or moving it.
Troubleshoot
advanced
2:00remaining
Troubleshooting nginx site config not loading
You added a new site config file in /etc/nginx/sites-available/ and created a symlink in /etc/nginx/sites-enabled/. After reloading nginx, the site does not respond. What is the most likely cause?
AThe config file is in JSON format instead of nginx syntax
BThe symlink points to a non-existent file or has incorrect permissions
CThe server block in the config is missing a <code>listen</code> directive
Dnginx does not support multiple site config files
Attempts:
2 left
💡 Hint
Check if the symlink is valid and accessible by nginx.
🔀 Workflow
advanced
3:00remaining
Order of steps to add a new site with separate config
What is the correct order of steps to add a new website using separate config files in nginx?
A1,3,4,2
B1,2,3,4
C3,1,2,4
D1,3,2,4
Attempts:
2 left
💡 Hint
Always test config before reloading nginx.
Best Practice
expert
3:00remaining
Best practice for managing multiple site configs in nginx
Which practice is best for managing multiple site configurations in nginx to ensure easy maintenance and minimal downtime?
AUse separate config files per site in sites-available, enable with symlinks in sites-enabled, test configs before reload
BKeep all site configs in a single large file and reload nginx after every change
CEdit the main nginx.conf directly for each site and restart nginx service to apply
DStore site configs in random directories and include them manually in nginx.conf
Attempts:
2 left
💡 Hint
Modular config files and testing before reload reduce errors and downtime.