0
0
Nginxdevops~20 mins

Why advanced patterns solve complex requirements in Nginx - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
NGINX Advanced Patterns Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Why use advanced NGINX patterns for complex routing?

Which reason best explains why advanced NGINX configuration patterns are used for complex routing requirements?

AThey reduce server memory usage by disabling modules.
BThey allow combining multiple conditions and variables to control request flow precisely.
CThey automatically update NGINX without manual reloads.
DThey simplify the configuration by removing all conditional checks.
Attempts:
2 left
💡 Hint

Think about how complex rules need precise control over requests.

💻 Command Output
intermediate
1:30remaining
Output of NGINX config test with complex if conditions

What is the output when running nginx -t on this configuration snippet?

server {
  listen 80;
  if ($request_method = POST) {
    return 405;
  }
}
Anginx: configuration file /etc/nginx/nginx.conf test is successful
Bnginx: [error] invalid parameter "POST" in if condition
Cnginx: [emerg] "if" directive is not allowed here in /etc/nginx/nginx.conf:3
Dnginx: [warn] unknown directive "if" in /etc/nginx/nginx.conf:3
Attempts:
2 left
💡 Hint

Check if the if directive is valid inside server block.

Configuration
advanced
2:00remaining
Correct advanced NGINX pattern for conditional proxy pass

Which configuration snippet correctly proxies requests to http://backend1 if the URI starts with /api/, otherwise to http://backend2?

A
location / {
  if ($uri ~ ^/api/) {
    proxy_pass http://backend1;
  }
  proxy_pass http://backend2;
}
B
location /api/ {
  proxy_pass http://backend1;
}
location / {
  proxy_pass http://backend2;
}
C
location / {
  set $target backend2;
  if ($uri ~ ^/api/) {
    set $target backend1;
  }
  proxy_pass http://$target;
}
D
location / {
  proxy_pass http://backend2;
  if ($uri ~ ^/api/) {
    proxy_pass http://backend1;
  }
}
Attempts:
2 left
💡 Hint

Consider how to use variables and conditions to choose proxy target in one location block.

Troubleshoot
advanced
2:00remaining
Troubleshooting NGINX rewrite loop with advanced patterns

Given this snippet, what is the cause of the rewrite loop?

location /app/ {
  rewrite ^/app/(.*)$ /$1 break;
  proxy_pass http://backend;
}
AThe rewrite changes URI but does not stop processing, causing repeated rewrites.
BThe proxy_pass directive is missing a trailing slash causing loop.
CThe rewrite uses 'break' which prevents further processing and causes loop.
DThe location block is missing 'last' flag in rewrite causing loop.
Attempts:
2 left
💡 Hint

Think about how rewrite flags affect URI processing and loops.

🔀 Workflow
expert
2:30remaining
Order of directives for advanced NGINX caching with conditional bypass

What is the correct order of directives to implement caching that bypasses cache for logged-in users using the $cookie_logged_in variable?

A4,2,1,3
B2,1,4,3
C1,2,3,4
D2,4,1,3
Attempts:
2 left
💡 Hint

Consider the order NGINX expects cache setup and bypass directives before proxying.