Bird
0
0

What will be the effect of this Nginx config when proxying to Flask?

medium📝 component behavior Q5 of 15
Flask - Deployment
What will be the effect of this Nginx config when proxying to Flask?
location /app {
    proxy_pass http://127.0.0.1:5000;
}
Client requests http://example.com/app/page.
ARequest forwarded to http://127.0.0.1:5000/app/page
BRequest forwarded to http://127.0.0.1:5000/page
CRequest forwarded to http://127.0.0.1:5000/app
DRequest returns 403 Forbidden
Step-by-Step Solution
Solution:
  1. Step 1: Understand proxy_pass without trailing slash

    When proxy_pass URL has no trailing slash, Nginx appends the full request URI after the location prefix.
  2. Step 2: Apply to example

    Location is /app, proxy_pass is http://127.0.0.1:5000. So request /app/page is appended fully, forwarding to http://127.0.0.1:5000/page.
  3. Final Answer:

    Request forwarded to http://127.0.0.1:5000/page -> Option B
  4. Quick Check:

    No trailing slash means location prefix replaced with proxy_pass URI [OK]
Quick Trick: No trailing slash in proxy_pass means location prefix is replaced [OK]
Common Mistakes:
MISTAKES
  • Confusing trailing slash behavior
  • Assuming path is stripped incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes