Bird
0
0

What will happen if Nginx is configured with this snippet and Django is running on port 8000?

medium📝 component behavior Q5 of 15
Django - Deployment and Production
What will happen if Nginx is configured with this snippet and Django is running on port 8000?
location / {
    proxy_pass http://localhost:8000;
    proxy_set_header Host $host;
}
And a client requests /admin/?
ANginx redirects to /admin/ on another server
BNginx serves a static admin page
CNginx returns a 403 Forbidden error
DNginx forwards the request to Django on port 8000
Step-by-Step Solution
Solution:
  1. Step 1: Analyze proxy_pass directive

    The proxy_pass sends all requests under / to Django backend at localhost:8000.
  2. Step 2: Understand proxy_set_header

    This header preserves the original host, important for Django to handle requests correctly.
  3. Final Answer:

    Nginx forwards the request to Django on port 8000 -> Option D
  4. Quick Check:

    Proxy forwards requests = A [OK]
Quick Trick: proxy_pass sends requests to backend server [OK]
Common Mistakes:
MISTAKES
  • Thinking Nginx serves admin static files
  • Expecting error without backend
  • Confusing redirect with proxy_pass

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes