Bird
0
0

Given this Nginx config snippet, what happens when a client requests /media/image.png?

medium📝 component behavior Q4 of 15
Django - Deployment and Production
Given this Nginx config snippet, what happens when a client requests /media/image.png?
location /media/ {
    alias /var/www/media/;
}
ANginx redirects to /media/image.png on Django
BNginx forwards the request to Django backend
CNginx serves the file from /var/www/media/image.png
DNginx returns a 404 error
Step-by-Step Solution
Solution:
  1. Step 1: Understand alias directive in Nginx

    The alias directive maps the URL path to a filesystem path directly.
  2. Step 2: Map requested URL to filesystem

    Request /media/image.png maps to /var/www/media/image.png served by Nginx.
  3. Final Answer:

    Nginx serves the file from /var/www/media/image.png -> Option C
  4. Quick Check:

    Alias serves static files = D [OK]
Quick Trick: Alias serves files directly from filesystem path [OK]
Common Mistakes:
MISTAKES
  • Assuming request is forwarded to Django
  • Confusing alias with proxy_pass
  • Expecting redirect instead of direct serving

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes