Bird
0
0

Why is it important to set the Host header with proxy_set_header Host $host; in Nginx when proxying to Django?

hard📝 Conceptual Q10 of 15
Django - Deployment and Production
Why is it important to set the Host header with proxy_set_header Host $host; in Nginx when proxying to Django?
AIt enables gzip compression automatically
BIt speeds up static file serving
CDjango uses the Host header to build correct URLs and for security checks
DIt caches responses on the client side
Step-by-Step Solution
Solution:
  1. Step 1: Understand Host header role

    Django relies on the Host header to generate absolute URLs and validate allowed hosts.
  2. Step 2: Importance in proxy setup

    Setting proxy_set_header Host $host; preserves the original Host header from the client.
  3. Final Answer:

    Django uses the Host header to build correct URLs and for security checks -> Option C
  4. Quick Check:

    Host header needed for URLs and security = C [OK]
Quick Trick: Host header ensures correct URLs and security in Django [OK]
Common Mistakes:
MISTAKES
  • Thinking Host header affects static files
  • Assuming it controls gzip compression
  • Believing it manages client caching

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes