0
0
Nginxdevops~10 mins

Location matching priority order 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 define an exact match location in nginx.

Nginx
location [1] /exact {
    proxy_pass http://backend;
}
Drag options to blanks, or click blank then click option'
A~
B^~
C=
D~*
Attempts:
3 left
💡 Hint
Common Mistakes
Using ~ or ~* instead of = for exact match
Using ^~ which is for prefix match, not exact
2fill in blank
medium

Complete the code to define a case-insensitive regular expression location.

Nginx
location [1] \.jpg$ {
    root /images;
}
Drag options to blanks, or click blank then click option'
A~
B~*
C=
D^~
Attempts:
3 left
💡 Hint
Common Mistakes
Using ~ instead of ~* for case-insensitive matching
Using = or ^~ which are not regex modifiers
3fill in blank
hard

Fix the error in the location block to make it a prefix match with higher priority.

Nginx
location [1] /images/ {
    root /data;
}
Drag options to blanks, or click blank then click option'
A=
B~
C~*
D^~
Attempts:
3 left
💡 Hint
Common Mistakes
Using = which is exact match, not prefix
Using ~ or ~* which are regex modifiers
4fill in blank
hard

Fill both blanks to create a regex location that matches .png files case-sensitively.

Nginx
location [1] \.png$ {
    root [2];
}
Drag options to blanks, or click blank then click option'
A~
B/var/www/images
C/usr/share/nginx/html
D~*
Attempts:
3 left
💡 Hint
Common Mistakes
Using ~* for case-insensitive instead of ~
Choosing wrong root directory
5fill in blank
hard

Fill all three blanks to create a location block that matches exactly /api, proxies to backend, and sets a header.

Nginx
location [1] /api {
    proxy_pass [2];
    proxy_set_header [3] $host;
}
Drag options to blanks, or click blank then click option'
A=
Bhttp://backend_server
CHost
D~
Attempts:
3 left
💡 Hint
Common Mistakes
Using ~ instead of = for exact match
Wrong proxy_pass URL
Incorrect header name