Bird
Raised Fist0
Nginxdevops~20 mins

Why reverse proxying serves backend applications in Nginx - Challenge Your Understanding

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Reverse Proxy Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why use a reverse proxy with backend apps?

Which of the following is the main reason to use a reverse proxy like Nginx in front of backend applications?

ATo improve security by hiding backend servers from direct internet access
BTo increase the size of backend application code
CTo slow down client requests intentionally
DTo replace backend applications with static files
Attempts:
2 left
💡 Hint

Think about how a reverse proxy acts as a middleman between clients and servers.

💻 Command Output
intermediate
2:00remaining
Nginx reverse proxy configuration effect

Given this Nginx config snippet, what happens when a client requests http://example.com/api/data?

Nginx
location /api/ {
    proxy_pass http://localhost:5000/;
}
ANginx forwards the request to http://localhost:5000/data
BNginx returns a 404 error immediately
CNginx serves a static file from /api/data
DNginx blocks the request due to missing SSL
Attempts:
2 left
💡 Hint

Look at how proxy_pass rewrites the URL path.

❓ Troubleshoot
advanced
2:00remaining
Backend app unreachable behind reverse proxy

You configured Nginx as a reverse proxy to a backend app on port 8080. Clients get a 502 Bad Gateway error. What is the most likely cause?

AClient IP is blocked by firewall rules on Nginx server
BNginx configuration file has a syntax error
CBackend app is not running or not listening on port 8080
DDNS for example.com is not set up
Attempts:
2 left
💡 Hint

502 Bad Gateway means Nginx cannot connect to the backend server.

🔀 Workflow
advanced
3:00remaining
Steps to add SSL termination with Nginx reverse proxy

What is the correct order of steps to enable HTTPS with SSL termination on Nginx reverse proxy?

A1,3,2,4
B1,2,3,4
C2,1,3,4
D4,1,2,3
Attempts:
2 left
💡 Hint

Think about preparing certificates before configuring Nginx.

✅ Best Practice
expert
2:30remaining
Why enable caching in reverse proxy for backend apps?

What is the main benefit of enabling caching in a reverse proxy like Nginx for backend applications?

AAutomatically update backend application code
BIncrease backend CPU usage by duplicating requests
CPrevent clients from accessing backend apps entirely
DReduce backend load and improve response time for repeated requests
Attempts:
2 left
💡 Hint

Think about how caching stores responses to serve faster next time.

Practice

(1/5)
1. What is the main purpose of using a reverse proxy like nginx for backend applications?
easy
A. To store user data permanently
B. To replace the backend application entirely
C. To act as a middleman between users and backend servers
D. To directly expose backend servers to the internet

Solution

  1. Step 1: Understand the role of a reverse proxy

    A reverse proxy sits between users and backend servers, forwarding requests and responses.
  2. Step 2: Identify the main purpose

    It improves security and performance by hiding backend details and managing traffic.
  3. Final Answer:

    To act as a middleman between users and backend servers -> Option C
  4. Quick Check:

    Reverse proxy = Middleman [OK]
Hint: Reverse proxy = middleman between user and backend [OK]
Common Mistakes:
  • Thinking reverse proxy replaces backend apps
  • Assuming it stores user data
  • Believing it exposes backend directly
2. Which nginx directive is used to forward client requests to a backend server in reverse proxy setup?
easy
A. proxy_pass
B. server_name
C. listen
D. root

Solution

  1. Step 1: Identify nginx directives related to proxying

    The directive that forwards requests to backend servers is proxy_pass.
  2. Step 2: Differentiate from other directives

    server_name sets domain, listen sets port, root sets file path.
  3. Final Answer:

    proxy_pass -> Option A
  4. Quick Check:

    Forward requests = proxy_pass [OK]
Hint: proxy_pass forwards requests to backend [OK]
Common Mistakes:
  • Confusing proxy_pass with server_name
  • Using listen to forward requests
  • Mistaking root for proxying
3. Given this nginx config snippet, what happens when a user accesses http://example.com/api/?
location /api/ {
    proxy_pass http://backend_server/;
}
medium
A. Requests to /api/ are forwarded to http://backend_server/
B. Requests to /api/ are forwarded to http://backend_server/api/
C. Requests to /api/ are served from nginx root directory
D. Requests to /api/ cause a 404 error

Solution

  1. Step 1: Understand proxy_pass behavior with trailing slash

    When proxy_pass URL ends with a slash, nginx replaces the matching part of the request URI.
  2. Step 2: Apply to given config

    Request to /api/ is forwarded to backend_server root /, so /api/ is replaced by /.
  3. Final Answer:

    Requests to /api/ are forwarded to http://backend_server/ -> Option A
  4. Quick Check:

    proxy_pass with trailing slash replaces matching URI [OK]
Hint: Trailing slash in proxy_pass replaces matching URI part [OK]
Common Mistakes:
  • Assuming URI is appended instead of replaced
  • Thinking nginx serves files locally
  • Expecting 404 without backend
4. You configured nginx as a reverse proxy but get a 502 Bad Gateway error. Which is the most likely cause?
medium
A. server_name directive is incorrect
B. proxy_pass directive is missing a semicolon
C. nginx is listening on the wrong port
D. Backend server is down or unreachable

Solution

  1. Step 1: Understand 502 Bad Gateway meaning

    502 means nginx cannot connect to the backend server to get a valid response.
  2. Step 2: Identify common causes

    The backend server being down or unreachable is the most common cause of 502 errors.
  3. Final Answer:

    Backend server is down or unreachable -> Option D
  4. Quick Check:

    502 error = backend unreachable [OK]
Hint: 502 error usually means backend server unreachable [OK]
Common Mistakes:
  • Blaming missing semicolon for 502 error
  • Confusing port listen issues with backend errors
  • Assuming server_name causes 502
5. You want nginx to serve static files directly but forward API requests to a backend app. Which config snippet correctly achieves this?
hard
A. location / { proxy_pass http://backend/; } location /api/ { root /var/www/html; }
B. location /api/ { proxy_pass http://backend/; } location / { root /var/www/html; }
C. location /api/ { root /var/www/html; } location / { proxy_pass http://backend/; }
D. location / { root /var/www/html; proxy_pass http://backend/; }

Solution

  1. Step 1: Separate static and API requests

    Static files should be served from nginx root for /, API requests proxied under /api/.
  2. Step 2: Check config snippet correctness

    location /api/ { proxy_pass http://backend/; } location / { root /var/www/html; } correctly proxies /api/ to backend and serves / from local files.
  3. Final Answer:

    location /api/ { proxy_pass http://backend/; } location / { root /var/www/html; } -> Option B
  4. Quick Check:

    Static on /, API on /api/ with proxy_pass [OK]
Hint: Proxy API path, serve static root separately [OK]
Common Mistakes:
  • Reversing proxy and root locations
  • Combining proxy_pass and root in same block
  • Serving API requests from root directory
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard