Complete the code to define an event handler for HTTP requests in NGINX.
server {
listen 80;
location / {
[1];
}
}proxy_pass without defining a backend.root without specifying a file.error_page which handles errors, not normal requests.The return 200 'Hello World' directive sends a simple response, acting as an event handler for HTTP requests.
Complete the code to trigger an event when a client connects using the NGINX stream module.
stream {
server {
listen 12345;
[1];
}
}return in stream context which is invalid.root which is for HTTP context.error_page which handles errors, not connections.The proxy_pass directive forwards the connection to a backend server, triggering an event on client connect.
Fix the error in the event-driven NGINX configuration to correctly log client connections.
events {
[1] 1024;
}worker_processes inside events block.client_max_body_size which is unrelated.error_log which is for logging errors.The worker_connections directive sets the maximum number of simultaneous connections per worker, essential for event handling.
Fill both blanks to create a map that triggers different actions based on request method.
map $request_method $action {
GET [1];
POST [2];
}proxy_pass inside map values which is invalid.default as a value for specific methods.The map assigns 1 for GET requests and 0 for POST requests, which can be used to trigger different actions.
Fill all three blanks to define a server block that triggers an event on a specific URI and proxies the request.
server {
listen 80;
location [1] {
[2] http://backend;
[3] 10s;
}
}proxy_pass causing no forwarding.The location /api/event matches the event URI, proxy_pass forwards the request, and proxy_read_timeout sets the timeout for the proxy response.