Skip to content
Foxipa
Code Completion 5 Challenges

Complete the config: Nginx Traffic Control

Fill in rate limiting, bursts, connection caps, and traffic splitting.

Intermediate ~4 min read

Challenge 1

Declare a per-client-IP rate limit of 10 requests per second.

nginx Your answer
limit_req_zone $binary_remote_addr zone=api:10m ;

Press Ctrl⌘Enter to check your answer

Challenge 2

Apply the zone with a 20-request burst served immediately.

nginx Your answer
location /api/ {
     zone=api burst=20 nodelay;
    proxy_pass http://backend;
}

Press Ctrl⌘Enter to check your answer

Challenge 3

Track concurrent connections per client IP.

nginx Your answer
limit_conn_zone $binary_remote_addr =perip:10m;

Press Ctrl⌘Enter to check your answer

Challenge 4

Send 5% of users to the slow rollout.

nginx Your answer
 "${remote_addr}${http_user_agent}" $variant {
    5%     .slow;
    *      .fast;
}

Press Ctrl⌘Enter to check your answer

Challenge 5

Flag traffic from a trusted internal range.

nginx Your answer
 $internal {
    default      0;
    10.0.0.0/8   1;
}

Press Ctrl⌘Enter to check your answer