Bird
0
0

Which Nginx configuration snippet correctly sets it as a reverse proxy forwarding requests to a Django app running on port 8000?

easy📝 Syntax Q12 of 15
Django - Deployment and Production
Which Nginx configuration snippet correctly sets it as a reverse proxy forwarding requests to a Django app running on port 8000?
Alocation / { proxy_pass http://127.0.0.1:8000; }
Blocation / { root /var/www/html; }
Clocation / { fastcgi_pass 127.0.0.1:8000; }
Dlocation / { proxy_redirect off; }
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct proxy directive

    To forward requests, Nginx uses proxy_pass with the Django app address and port.
  2. Step 2: Check other options for correctness

    root serves static files, fastcgi_pass is for FastCGI apps, and proxy_redirect controls redirects but doesn't forward requests.
  3. Final Answer:

    location / { proxy_pass http://127.0.0.1:8000; } -> Option A
  4. Quick Check:

    Use proxy_pass for reverse proxy [OK]
Quick Trick: proxy_pass forwards requests to backend server [OK]
Common Mistakes:
MISTAKES
  • Using root instead of proxy_pass for proxying
  • Confusing fastcgi_pass with proxy_pass
  • Omitting the backend address in proxy_pass

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes