Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions tools/reverse-proxy/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,30 @@ http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

# Log format for errors (4xx and 5xx) - excludes successful requests
# Dimensions: IP, timestamp, method, request URL (includes query string), status, referrer
log_format errors_only '$remote_addr [$time_local] $request_method "$request_uri" $status "$http_referer"';
# Log format - includes IP, timestamp, method, URL, status, referrer
log_format main '$remote_addr [$time_local] $request_method "$request_uri" $status "$http_referer"';

# Map to conditionally log only 4xx and 5xx errors
map $status $log_errors_only {
# Map to identify errors (4xx/5xx)
map $status $is_error {
~^[45] 1;
default 0;
}

access_log /var/log/nginx/access.log errors_only if=$log_errors_only;
# Map to identify healthcheck requests
map $request_uri $is_healthcheck {
~^/ops/healthcheck 1;
default 0;
}

# Combine: log if error OR healthcheck
map "$is_error:$is_healthcheck" $should_log {
"1:0" 1;
"1:1" 1;
"0:1" 1;
default 0;
}

access_log /var/log/nginx/access.log main if=$should_log;

sendfile on;

Expand Down