0
0
Nginxdevops~5 mins

Upstream blocks in Nginx - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is an upstream block in nginx?
An upstream block defines a group of backend servers that nginx can proxy requests to. It helps distribute traffic among multiple servers.
Click to reveal answer
beginner
How do you define multiple servers inside an upstream block?
Inside the upstream block, list each server with the server directive, for example:<br>
upstream backend {
  server 192.168.1.10;
  server 192.168.1.11;
}
Click to reveal answer
beginner
What is the purpose of the proxy_pass directive in relation to upstream blocks?
The proxy_pass directive tells nginx to forward client requests to the servers defined in an upstream block, enabling load balancing.
Click to reveal answer
intermediate
Name two load balancing methods supported in nginx upstream blocks.
Two common methods are:<br>1. round-robin (default): requests are distributed evenly.<br>2. least_conn: requests go to the server with the fewest active connections.
Click to reveal answer
intermediate
How can you mark a server as a backup in an upstream block?
Add the backup parameter to the server directive. This server will only receive traffic if all primary servers are down.<br>
server 192.168.1.12 backup;
Click to reveal answer
What does an upstream block in nginx do?
AConfigures SSL certificates
BSets client request timeout
CDefines backend servers for load balancing
DSpecifies static file locations
Which directive inside an upstream block lists backend servers?
Aproxy_pass
Bserver
Clocation
Dlisten
What is the default load balancing method in nginx upstream blocks?
Around-robin
Bip_hash
Crandom
Dleast_conn
How do you tell nginx to use an upstream block in a server configuration?
AUsing <code>proxy_pass</code> with the upstream name
BUsing <code>listen</code> directive
CUsing <code>root</code> directive
DUsing <code>error_page</code>
What does the backup parameter do in an upstream server directive?
AMarks the server as primary
BEnables SSL on the server
CDisables the server
DMarks the server as a fallback used only if others fail
Explain how nginx uses an upstream block to balance load between servers.
Think about how nginx forwards requests to several servers.
You got /4 concepts.
    Describe how to configure a backup server in an nginx upstream block and why it is useful.
    Consider what happens if main servers go down.
    You got /4 concepts.