0
0
Nginxdevops~20 mins

Include directive for modular config in Nginx - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Nginx Modular Config Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the effect of this nginx config snippet?
Given this nginx configuration snippet, what will be the result when nginx starts?
http {
    include /etc/nginx/conf.d/*.conf;
}
Nginx
http {
    include /etc/nginx/conf.d/*.conf;
}
Anginx loads only the first .conf file found in /etc/nginx/conf.d/
Bnginx ignores the include directive because wildcards are not supported
Cnginx throws a syntax error due to invalid include path
Dnginx loads all configuration files ending with .conf from /etc/nginx/conf.d/ directory
Attempts:
2 left
💡 Hint
The include directive supports wildcards to modularize configs.
Configuration
intermediate
2:00remaining
Choose the correct syntax to include a single config file
Which option correctly includes the file /etc/nginx/sites-enabled/example.conf inside the server block?
Nginx
server {
    # include directive here
}
Ainclude /etc/nginx/sites-enabled/example.conf;
Binclude "/etc/nginx/sites-enabled/example.conf"
Cinclude /etc/nginx/sites-enabled/example.conf
Dinclude '/etc/nginx/sites-enabled/example.conf';
Attempts:
2 left
💡 Hint
Include directive requires a semicolon at the end.
Troubleshoot
advanced
2:00remaining
Why does nginx fail to start with this include?
You added this line to your nginx.conf:
include /etc/nginx/conf.d/*.conf;

But nginx fails to start with an error:
nginx: [emerg] open() "/etc/nginx/conf.d/invalid.conf" failed (2: No such file or directory)
What is the most likely cause?
Nginx
include /etc/nginx/conf.d/*.conf;
AThe include directive does not support wildcards in nginx
BOne of the files matched by the wildcard does not exist or has been deleted
CThe directory /etc/nginx/conf.d/ does not have read permissions
Dnginx.conf syntax error unrelated to include
Attempts:
2 left
💡 Hint
Check if all files matched by the wildcard exist.
🔀 Workflow
advanced
3:00remaining
Order the steps to modularize nginx config using include
Put these steps in the correct order to modularize nginx configuration using the include directive:
A1,3,2,4
B2,1,3,4
C3,1,2,4
D1,2,3,4
Attempts:
2 left
💡 Hint
Think about creating directory before placing files and including them.
Best Practice
expert
2:00remaining
Which practice is best for modular nginx config using include?
Which option is the best practice for organizing nginx configuration files using the include directive?
AUse include directive only for SSL certificates paths
BPut all configuration in a single large nginx.conf file without includes
CUse include with wildcards to load multiple small config files grouped by function or site
DAvoid using include directive to prevent complexity
Attempts:
2 left
💡 Hint
Modular config helps maintainability and clarity.