Skip to content
Foxipa
Code Completion 5 Challenges

Complete the config: Nginx Observability

Fill in log formats, JSON escaping, and stub_status.

Advanced ~4 min read

Challenge 1

Define a named access-log schema.

nginx Your answer
 main '$remote_addr [$time_local] "$request" $status $upstream_response_time';

Press Ctrl⌘Enter to check your answer

Challenge 2

Make the access log safe JSON.

nginx Your answer
log_format =json combined_json '{"ts":"$time_iso8601","uri":"$uri","status":$status}';

Press Ctrl⌘Enter to check your answer

Challenge 3

Expose the built-in status counters on localhost only.

nginx Your answer
server {
    location = /status {
        allow 127.0.0.1;
        deny all;
        ;
    }
}

Press Ctrl⌘Enter to check your answer

Challenge 4

Log the cache path each response took.

nginx Your answer
log_format cache '$uri $status  $upstream_addr';

Press Ctrl⌘Enter to check your answer

Challenge 5

Raise the error log to notice level for this server.

nginx Your answer
server {
     /var/log/nginx/app.error.log notice;
}

Press Ctrl⌘Enter to check your answer