0
0
Nginxdevops~5 mins

Prefix match in Nginx - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a prefix match in nginx configuration?
A prefix match in nginx is a way to match the beginning part of a URL path to decide how to handle the request. It checks if the URL starts with a specific string.
Click to reveal answer
beginner
How do you define a prefix match location block in nginx?
You define it by using location /prefix/ { ... } without any special symbols. This matches any URL starting with '/prefix/'.
Click to reveal answer
intermediate
What is the difference between prefix match and exact match in nginx?
Prefix match checks if the URL starts with a string, while exact match uses = to match the URL exactly with no extra characters.
Click to reveal answer
intermediate
What happens if multiple prefix matches apply to a request in nginx?
Nginx chooses the longest matching prefix. For example, if both /app/ and /app/api/ match, it picks /app/api/.
Click to reveal answer
beginner
Can prefix matches in nginx use regular expressions?
No, prefix matches are simple string matches. Regular expressions require ~ or ~* modifiers in location blocks.
Click to reveal answer
Which nginx location block uses prefix match?
Alocation /images/ { }
Blocation = /images/ { }
Clocation ~ /images/ { }
Dlocation ^~ /images/ { }
If you have location /app/ and location /app/api/, which one handles /app/api/users?
Alocation /app/api/
BBoth equally
Clocation /app/
DNeither
What symbol marks an exact match in nginx location?
A~
B=
C^~
D*
Can prefix match location blocks use regular expressions?
AYes, always
BOnly with =
CNo, never
DOnly with ^~
What does the '^~' modifier do in nginx location?
APrefix match with higher priority
BRegex match
CExact match
DCase-insensitive match
Explain how nginx chooses a location block when multiple prefix matches exist.
Think about which prefix is the longest that fits the URL.
You got /3 concepts.
    Describe the difference between prefix match and exact match in nginx location blocks.
    Consider how nginx treats the URL string in each case.
    You got /3 concepts.