0
0
Nginxdevops~20 mins

Request body handling in Nginx - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Request Body 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 the directive 'client_max_body_size 1m;' in nginx?

Consider the nginx configuration snippet below:

client_max_body_size 1m;

What happens when a client sends a request body larger than 1 megabyte?

Anginx returns a 413 Request Entity Too Large error to the client.
Bnginx silently truncates the request body to 1 megabyte and processes it.
Cnginx accepts the full request body but logs a warning.
Dnginx closes the connection without any response.
Attempts:
2 left
💡 Hint

Think about how nginx enforces limits on client request sizes.

Configuration
intermediate
2:00remaining
How to configure nginx to save client request bodies to a specific directory?

You want nginx to save the full client request body to files in /var/tmp/nginx_body for later inspection. Which configuration snippet correctly enables this?

Aclient_body_save /var/tmp/nginx_body;
Bclient_body_directory /var/tmp/nginx_body;
Cclient_body_path /var/tmp/nginx_body;
Dclient_body_temp_path /var/tmp/nginx_body 1 2;
Attempts:
2 left
💡 Hint

Look for the directive that controls the temporary storage path for client request bodies.

Troubleshoot
advanced
2:30remaining
Why does nginx return a 400 Bad Request when client_body_buffer_size is too small?

Given this nginx configuration:

client_body_buffer_size 1k;

A client sends a POST request with a 2 KB body. nginx returns a 400 Bad Request error. Why?

AThe buffer size is too small to hold the entire request body in memory, and nginx fails to buffer it properly.
Bnginx does not support buffering request bodies larger than 1 KB.
CThe client request body is corrupted, causing nginx to reject it.
DThe 400 error is unrelated to buffer size and caused by a syntax error in the configuration.
Attempts:
2 left
💡 Hint

Consider how nginx buffers client request bodies before processing.

🔀 Workflow
advanced
2:30remaining
Order the steps nginx follows to handle a client request body

Arrange the following steps in the correct order nginx processes a client request body:

A2,1,4,3
B1,2,3,4
C1,4,2,3
D1,2,4,3
Attempts:
2 left
💡 Hint

Think about how nginx validates size before reading the body.

Best Practice
expert
3:00remaining
Which nginx configuration best prevents denial-of-service attacks via large request bodies?

You want to protect your nginx server from clients sending very large request bodies that could exhaust resources. Which configuration snippet is the best practice?

Aclient_max_body_size 10m; client_body_buffer_size 128k;
Bclient_max_body_size 1m; client_body_buffer_size 512k;
Cclient_max_body_size 100m; client_body_buffer_size 1m;
Dclient_max_body_size 0; client_body_buffer_size 64k;
Attempts:
2 left
💡 Hint

Consider reasonable limits to block very large bodies but allow normal usage.