0
0
Nginxdevops~10 mins

Prefix match in Nginx - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to match all requests starting with /images/.

Nginx
location [1] /images/ { }
Drag options to blanks, or click blank then click option'
A^~
B~
C/
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using ~ which is for regex match.
Using = which is for exact match.
Using / which is default prefix but without stopping further regex checks.
2fill in blank
medium

Complete the code to match requests exactly equal to /about.

Nginx
location [1] /about { }
Drag options to blanks, or click blank then click option'
A~
B^~
C/
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using / which matches prefix, not exact.
Using ^~ which matches prefix but not exact.
Using ~ which is for regex.
3fill in blank
hard

Fix the error in this location block to match all URIs starting with /api/ without regex.

Nginx
location [1] /api/ { }
Drag options to blanks, or click blank then click option'
A/
B=
C^~
D~
Attempts:
3 left
💡 Hint
Common Mistakes
Using ~ which treats /api/ as regex.
Using = which matches exact URI only.
Using / which allows regex locations to override.
4fill in blank
hard

Fill both blanks to create a location block that matches URIs starting with /static/ and disables regex checks.

Nginx
location [1] [2] { }
Drag options to blanks, or click blank then click option'
A^~
B/static/
C~
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using ~ which is regex and does not disable further checks.
Using = which matches exact URI only.
Swapping the order of modifier and URI.
5fill in blank
hard

Fill all three blanks to create a location block that matches URIs starting with /docs/, disables regex, and sets root to /var/www/docs.

Nginx
location [1] [2] {
    root [3];
}
Drag options to blanks, or click blank then click option'
A^~
B/docs/
C/var/www/docs
D~
Attempts:
3 left
💡 Hint
Common Mistakes
Using ~ which is regex and does not disable further checks.
Using wrong root path.
Swapping modifier and URI.