0
0
Nginxdevops~20 mins

First Nginx configuration - 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 the command to test Nginx configuration?
You have created a new Nginx configuration file. Which command will correctly test the syntax of this configuration and what will be the output if the syntax is correct?
Nginx
sudo nginx -t
A
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
BSyntax error in /etc/nginx/nginx.conf at line 10
Cnginx: command not found
DFailed to start nginx.service: Unit nginx.service not found.
Attempts:
2 left
💡 Hint
Use the command that checks Nginx configuration syntax without starting the server.
Configuration
intermediate
2:00remaining
Identify the correct server block to serve a static website on port 8080
You want Nginx to serve a static website from /var/www/html on port 8080. Which server block configuration is correct?
Aserver { listen 8080; root /var/www; index index.html; }
Bserver { listen 8080; root /var/www/html; index index.html; }
Cserver { listen 80; root /var/www/html; index index.html; }
Dserver { listen 8080; root /var/www/html; }
Attempts:
2 left
💡 Hint
The server block must listen on port 8080 and point root to the exact folder with index.html.
Troubleshoot
advanced
2:00remaining
Why does Nginx fail to start after adding a new server block?
You added this server block to your Nginx config but Nginx fails to start: server { listen 80; server_name example.com; root /var/www/example; index index.html; location / { try_files $uri $uri/ =404 } } What is the cause of the failure?
Nginx
server {
  listen 80;
  server_name example.com;
  root /var/www/example;
  index index.html;
  location / {
    try_files $uri $uri/ =404
  }
}
Aserver_name directive is invalid
BRoot directory /var/www/example does not exist
CMissing semicolon after 'try_files $uri $uri/ =404' causes syntax error
Dlisten directive must specify IP address
Attempts:
2 left
💡 Hint
Check the syntax carefully for missing punctuation.
🔀 Workflow
advanced
2:00remaining
Order the steps to safely reload Nginx after configuration changes
Put these steps in the correct order to safely apply new Nginx configuration changes without downtime.
A3,1,2,4
B1,3,2,4
C3,2,1,4
D2,3,1,4
Attempts:
2 left
💡 Hint
You must edit first, then test, then reload, then check status.
Best Practice
expert
2:00remaining
Which practice improves Nginx configuration maintainability?
You want to keep your Nginx configuration easy to manage as it grows. Which practice is best?
ADisable syntax testing to speed up reloads
BPut all server blocks in one large nginx.conf file
CAvoid comments to keep files clean
DUse include directives to split configuration into smaller files
Attempts:
2 left
💡 Hint
Think about how to organize files for clarity and ease of updates.