0
0
Nginxdevops~5 mins

Exact match (=) in Nginx - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the = symbol mean in an nginx location block?
It means the location will match the request URI exactly, without any extra characters or variations.
Click to reveal answer
beginner
How does nginx treat a location = /path compared to location /path?
The = /path matches only the exact URI /path, while /path matches any URI starting with /path.
Click to reveal answer
intermediate
Why use = for exact match in nginx locations?
To ensure that only requests with the exact URI are handled by that block, avoiding partial or prefix matches.
Click to reveal answer
intermediate
What happens if multiple nginx location blocks match a request URI and one uses =?
The exact match location with = is chosen first before prefix or regex matches.
Click to reveal answer
beginner
Write a simple nginx location block using exact match for URI /hello.
location = /hello { return 200 "Hello exact match!"; }
Click to reveal answer
What does location = /test match in nginx?
AAll URIs
BAny URI starting with /test
CAny URI containing /test anywhere
DOnly the URI exactly equal to /test
If you have location = /foo and location /foo, which handles the request to /foo?
Alocation /foo
BNeither
Clocation = /foo
DBoth equally
Can location = / be used to match only the homepage URI exactly?
AYes
BNo
COnly with regex
DOnly with prefix
What is the main benefit of using exact match = in nginx locations?
AMatches all URIs
BFaster matching for specific URIs
CAllows regex inside location
DDisables caching
Which symbol is used in nginx to specify an exact match in a location block?
A=
B^~
C~
D*
Explain how nginx processes location blocks when one uses exact match (=) and others use prefix matches.
Think about priority order in nginx location matching.
You got /4 concepts.
    Describe a scenario where using exact match (=) in nginx location is better than prefix match.
    Consider when you want to be very precise about which requests are handled.
    You got /4 concepts.