0
0
Nginxdevops~5 mins

Directives and blocks in Nginx - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a directive in nginx configuration?
A directive is a single instruction in nginx configuration that sets a specific parameter or behavior, like setting a port or enabling a feature.
Click to reveal answer
beginner
What is a block in nginx configuration?
A block groups multiple directives together inside curly braces { } to apply settings to a specific context, like a server or location.
Click to reveal answer
intermediate
How do directives and blocks relate in nginx config?
Directives can be simple single lines or can contain blocks. Blocks hold other directives inside them to organize settings hierarchically.
Click to reveal answer
beginner
Example of a simple directive in nginx?
Example:
listen 80;
This tells nginx to listen on port 80.
Click to reveal answer
beginner
Example of a block directive in nginx?
Example:
server {
    listen 80;
    server_name example.com;
}
This block configures a server with specific settings.
Click to reveal answer
What symbol starts a block in nginx configuration?
A[
B(
C{
D<
Which of these is a directive in nginx?
Alisten 80;
B{ listen 80; }
Cserver { listen 80; }
D<listen>80</listen>
What does a block in nginx configuration do?
AGroups directives for a context
BDefines a variable
CComments out code
DRuns a script
Which is the correct way to write a directive?
Alisten 80
Blisten 80;
Clisten: 80;
Dlisten = 80;
Where would you find blocks in nginx config?
AIn log files
BOnly at the top of the file
CIn comments
DInside server or location sections
Explain what directives and blocks are in nginx configuration and how they work together.
Think about single instructions versus grouped instructions.
You got /4 concepts.
    Describe how you would configure nginx to listen on port 80 using directives and blocks.
    Remember the structure of a server block.
    You got /3 concepts.