0
0
Nginxdevops~10 mins

Event-driven architecture in Nginx - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define an event handler for HTTP requests in NGINX.

Nginx
server {
    listen 80;
    location / {
        [1];
    }
}
Drag options to blanks, or click blank then click option'
Aproxy_pass http://backend
Broot /var/www/html
Creturn 200 'Hello World'
Derror_page 404 /404.html
Attempts:
3 left
💡 Hint
Common Mistakes
Using proxy_pass without defining a backend.
Using root without specifying a file.
Using error_page which handles errors, not normal requests.
2fill in blank
medium

Complete the code to trigger an event when a client connects using the NGINX stream module.

Nginx
stream {
    server {
        listen 12345;
        [1];
    }
}
Drag options to blanks, or click blank then click option'
Aroot /var/stream
Bproxy_pass backend:12345
Creturn 200 'Connected'
Derror_page 500 /500.html
Attempts:
3 left
💡 Hint
Common Mistakes
Using return in stream context which is invalid.
Using root which is for HTTP context.
Using error_page which handles errors, not connections.
3fill in blank
hard

Fix the error in the event-driven NGINX configuration to correctly log client connections.

Nginx
events {
    [1] 1024;
}
Drag options to blanks, or click blank then click option'
Aworker_connections
Bworker_processes
Cclient_max_body_size
Derror_log
Attempts:
3 left
💡 Hint
Common Mistakes
Using worker_processes inside events block.
Using client_max_body_size which is unrelated.
Using error_log which is for logging errors.
4fill in blank
hard

Fill both blanks to create a map that triggers different actions based on request method.

Nginx
map $request_method $action {
    GET [1];
    POST [2];
}
Drag options to blanks, or click blank then click option'
A1
B0
Cdefault
Dproxy_pass
Attempts:
3 left
💡 Hint
Common Mistakes
Using proxy_pass inside map values which is invalid.
Using default as a value for specific methods.
Mixing string and numeric values inconsistently.
5fill in blank
hard

Fill all three blanks to define a server block that triggers an event on a specific URI and proxies the request.

Nginx
server {
    listen 80;
    location [1] {
        [2] http://backend;
        [3] 10s;
    }
}
Drag options to blanks, or click blank then click option'
A/api/event
Bproxy_pass
Cproxy_read_timeout
D/home
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong location paths that don't match the event.
Omitting proxy_pass causing no forwarding.
Using incorrect timeout directives.