Bird
Raised Fist0
Nginxdevops~20 mins

Proxy timeouts in Nginx - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Proxy Timeout Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the effect of this nginx proxy timeout setting?
Given the nginx configuration snippet below, what will happen if the backend server takes longer than 10 seconds to respond?
Nginx
proxy_read_timeout 10s;
Anginx will wait indefinitely for the backend server to respond.
Bnginx will retry the request automatically to the backend server.
Cnginx will close the connection and return a 504 Gateway Timeout error to the client.
Dnginx will return a 502 Bad Gateway error immediately.
Attempts:
2 left
💡 Hint
Think about what 'proxy_read_timeout' controls in nginx.
❓ Configuration
intermediate
2:00remaining
Which configuration sets the maximum time nginx waits to establish a connection to the backend?
Select the correct nginx directive to limit the time nginx waits to connect to the backend server.
Aproxy_connect_timeout 5s;
Bproxy_send_timeout 5s;
Cproxy_read_timeout 5s;
Dclient_body_timeout 5s;
Attempts:
2 left
💡 Hint
Connecting to backend is different from sending or reading data.
❓ Troubleshoot
advanced
2:00remaining
Why does nginx return a 504 error despite a high proxy_read_timeout value?
An nginx server has proxy_read_timeout 120s; but clients still get 504 Gateway Timeout errors after 60 seconds. What is a likely cause?
AThe backend server closes the connection after 60 seconds.
BThe client closed the connection before 60 seconds.
CThe proxy_connect_timeout is set to 60 seconds.
DThe client_body_timeout is set to 60 seconds.
Attempts:
2 left
💡 Hint
Consider what controls the backend server's behavior.
✅ Best Practice
advanced
2:00remaining
What is a recommended practice to avoid proxy timeout errors in nginx for slow backend responses?
Choose the best practice to handle slow backend responses without causing frequent 504 errors.
ASet proxy_connect_timeout to 1 second to fail fast.
BIncrease proxy_read_timeout to a value longer than the expected backend response time.
CDisable proxy_read_timeout to wait indefinitely.
DSet client_body_timeout to a very low value.
Attempts:
2 left
💡 Hint
Think about how to give backend enough time to respond.
🔀 Workflow
expert
3:00remaining
Order the steps to troubleshoot nginx proxy timeout errors effectively
Arrange the steps in the correct order to troubleshoot frequent 504 Gateway Timeout errors in nginx proxy setups.
A2,3,1,4
B1,3,2,4
C1,2,3,4
D3,2,1,4
Attempts:
2 left
💡 Hint
Start by understanding backend behavior before changing nginx settings.

Practice

(1/5)
1. What does the proxy_connect_timeout directive control in Nginx?
easy
A. The time Nginx waits to receive the full response from the backend
B. The time Nginx waits to send the full request to the backend
C. The time Nginx waits to establish a connection with the backend server
D. The time Nginx caches the response from the backend

Solution

  1. Step 1: Understand proxy_connect_timeout purpose

    This directive sets how long Nginx waits to connect to the backend server before giving up.
  2. Step 2: Differentiate from other timeouts

    proxy_send_timeout controls sending request time, proxy_read_timeout controls response wait time, so they are different.
  3. Final Answer:

    The time Nginx waits to establish a connection with the backend server -> Option C
  4. Quick Check:

    proxy_connect_timeout = connection wait time [OK]
Hint: Connect timeout is for establishing backend connection only [OK]
Common Mistakes:
  • Confusing connect timeout with read or send timeout
  • Thinking it controls response wait time
  • Assuming it caches responses
2. Which of the following is the correct syntax to set a 10-second proxy read timeout in Nginx?
easy
A. proxy_read_timeout 10;
B. proxy_read_timeout 10s;
C. proxy_read_timeout = 10s;
D. proxy_read_timeout: 10s;

Solution

  1. Step 1: Recall Nginx timeout syntax

    Timeout values are set as numbers with optional time units, but seconds are default so '10' means 10 seconds.
  2. Step 2: Check syntax correctness

    Correct syntax is proxy_read_timeout 10; without '=' or ':' and without 's' suffix.
  3. Final Answer:

    proxy_read_timeout 10; -> Option A
  4. Quick Check:

    Timeouts use number only, no '=' or ':' [OK]
Hint: Use number only for seconds, no '=' or ':' in directives [OK]
Common Mistakes:
  • Adding '=' sign which is invalid
  • Using ':' instead of space
  • Adding 's' suffix which is not required
3. Given this Nginx config snippet:
location /api/ {
  proxy_pass http://backend;
  proxy_connect_timeout 5;
  proxy_send_timeout 10;
  proxy_read_timeout 15;
}

What happens if the backend server takes 20 seconds to send the full response?
medium
A. Nginx closes connection after 10 seconds waiting to send request
B. Nginx closes connection after 5 seconds trying to connect
C. Nginx waits indefinitely for the backend response
D. Nginx closes connection after 15 seconds waiting for response

Solution

  1. Step 1: Identify relevant timeout for response wait

    proxy_read_timeout controls how long Nginx waits for the backend to send the full response.
  2. Step 2: Compare backend response time with proxy_read_timeout

    Backend takes 20 seconds, proxy_read_timeout is 15 seconds, so Nginx closes the connection after 15 seconds.
  3. Final Answer:

    Nginx closes connection after 15 seconds waiting for response -> Option D
  4. Quick Check:

    Response wait = proxy_read_timeout = 15 [OK]
Hint: Response wait time controlled by proxy_read_timeout [OK]
Common Mistakes:
  • Confusing send timeout with read timeout
  • Assuming connect timeout applies to response wait
  • Thinking Nginx waits forever
4. You set proxy_connect_timeout 10; but Nginx still times out connecting to backend after 5 seconds. What is the likely cause?
medium
A. The backend server is closing connections early
B. There is a lower timeout set by proxy_connect_timeout in a lower-level block
C. Nginx ignores proxy_connect_timeout and uses default 5 seconds
D. The proxy_connect_timeout directive is misspelled

Solution

  1. Step 1: Understand directive inheritance in Nginx

    Timeout directives can be set at multiple levels; lower-level settings override higher-level ones.
  2. Step 2: Identify cause of shorter timeout

    If a lower-level block has a 5-second timeout, it overrides the 10-second setting.
  3. Final Answer:

    There is a lower timeout set by proxy_connect_timeout in a lower-level block -> Option B
  4. Quick Check:

    Timeouts can be overridden by lower-level config [OK]
Hint: Check for overriding timeouts in child blocks [OK]
Common Mistakes:
  • Assuming Nginx ignores the directive
  • Blaming backend without checking config
  • Misspelling directive (would cause error, not timeout)
5. You want Nginx to wait up to 20 seconds to connect to backend, 30 seconds to send the request, and 40 seconds to receive the response. Which configuration snippet correctly sets these timeouts?
hard
A. proxy_connect_timeout 20; proxy_send_timeout 30; proxy_read_timeout 40;
B. proxy_connect_timeout 20s; proxy_send_timeout 30s; proxy_read_timeout 40s;
C. proxy_connect_timeout=20; proxy_send_timeout=30; proxy_read_timeout=40;
D. proxy_connect_timeout: 20; proxy_send_timeout: 30; proxy_read_timeout: 40;

Solution

  1. Step 1: Recall correct syntax for timeout directives

    Timeouts are set as directive name followed by a space and number (seconds), ending with semicolon; no '=' or ':' or 's' suffix needed.
  2. Step 2: Validate each option

    proxy_connect_timeout 20; proxy_send_timeout 30; proxy_read_timeout 40; uses correct syntax; A uses ':'; B adds unnecessary 's'; C uses '='.
  3. Final Answer:

    proxy_connect_timeout 20; proxy_send_timeout 30; proxy_read_timeout 40; -> Option A
  4. Quick Check:

    Use number only with semicolon, no '=' or ':' [OK]
Hint: Timeouts use number only, no '=' or ':' [OK]
Common Mistakes:
  • Adding 's' suffix to numbers
  • Using '=' or ':' instead of space
  • Missing semicolon at line end
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