Recall & Review
beginner
What is a
location block in nginx?A
location block defines how nginx should respond to requests for specific URL paths. It helps route requests to different parts of your server or backend services.Click to reveal answer
beginner
How do you route API requests starting with
/api/ to a backend server in nginx?Use a
location /api/ { proxy_pass http://backend_server; } block to forward all requests starting with /api/ to the backend server.Click to reveal answer
beginner
What does the
proxy_pass directive do inside a location block?It tells nginx to forward the incoming request to another server or service, acting like a middleman between the client and backend.
Click to reveal answer
intermediate
How can you match exact URLs versus URL prefixes in nginx location blocks?
Use
= /exact/path for exact matches and /prefix/ for prefix matches. Exact matches take priority over prefix matches.Click to reveal answer
intermediate
Why is the order of location blocks important in nginx?
nginx chooses the best matching location block based on specific rules. Exact matches are checked first, then prefix matches. Order affects which block handles a request.
Click to reveal answer
Which nginx directive forwards API requests to a backend server?
✗ Incorrect
The
proxy_pass directive forwards requests to another server.How do you define a location block that matches all URLs starting with
/api/?✗ Incorrect
A simple prefix match uses
location /api/ {}.What happens if you have both
location = /api and location /api/ blocks?✗ Incorrect
Exact matches take priority over prefix matches.
Which directive specifies the port nginx listens on?
✗ Incorrect
The
listen directive sets the port for nginx.If you want to route
/api/users to a backend, which location block is best?✗ Incorrect
The prefix match
/api/ covers /api/users.Explain how nginx uses location blocks to route API requests.
Think about how nginx decides which block handles a request.
You got /4 concepts.
Describe how to configure nginx to send all requests starting with /api/ to a backend server.
Focus on the location block and proxy_pass.
You got /3 concepts.