Files
stpweb/.deprecated/nginx/payload_log.conf
adamfandClaude Opus 5.5 30d6056bc0
Test and deploy / test (push) Successful in 1m35s
Test and deploy / deploy (push) Successful in 1m10s
Move the retired nginx and certbot into .deprecated
Nothing references nginx/ or certbot/ since the cutover to Caddy (daa2a46),
so they join quartz, hasura and autoheal in .deprecated/, with a README
entry on how to bring them back. The rollback steps in DEPLOYMENT.md §7 now
revert this commit and then the cutover. The host keeps ./certbot/conf (the
last certbot certificate, valid until 2027-01-20) and ./logs/nginx until the
rollback is no longer wanted; .gitignore still covers certbot/conf and
certbot/www for that reason.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-17 23:35:33 +00:00

56 lines
2.6 KiB
Plaintext

# =============================================================================
# Payload log: one JSON line per request, body included, for inspecting what
# actually arrives at the edge. Included at http level by BOTH nginx.conf and
# nginx_dev.conf, so it is plain nginx (no envsubst) like security_headers.conf.
#
# WHERE IT GOES
# /var/log/nginx/payloads/ is bind-mounted from ./logs/nginx on the host.
# The `traffic` container tails the file to its stdout so Dozzle (/dozzle/)
# shows it as its own clean stream of JSON. The `compact` access log is
# untouched and still goes to the container's stdout.
#
# WHAT IS NOT CAPTURED
# - Bodies larger than client_body_buffer_size: nginx spools those to a
# temp file and leaves $request_body empty. Uploads therefore log with an
# empty body (their size is still in `len`).
# - Bodies of requests nginx answers itself (redirects, static files): it
# never reads them, so $request_body is empty there too.
# - Responses. nginx cannot log a proxied response body.
# - auth_request subrequests: log_subrequest is off by default.
# =============================================================================
# 64k keeps ordinary JSON/GraphQL bodies in memory (the default is 16k on
# 64-bit), which is the only case where $request_body is filled. It is a
# per-request buffer only allocated when a body arrives, so the cost is small.
client_body_buffer_size 64k;
# Redaction: any body mentioning a password, token or secret is logged as a
# placeholder rather than having the field stripped, because nginx has no JSON
# parser. That catches /auth/login, the GraphQL login and change-password
# mutations and the refresh-token call in one rule. Over-matching (a query that
# merely selects a field named *token*) costs a hidden body, never a leak.
# map is evaluated lazily at log time, after the body has been read.
map $request_body $logged_body {
"~*(password|token|secret)" "[redacted]";
default $request_body;
}
# escape=json makes each line valid JSON (quotes, newlines and control bytes
# in the body are escaped), so Dozzle renders it as fields and `jq` reads it.
log_format payloads escape=json '{'
'"time":"$time_iso8601",'
'"ip":"$remote_addr",'
'"method":"$request_method",'
'"host":"$host",'
'"uri":"$request_uri",'
'"status":"$status",'
'"rt":"$request_time",'
'"ctype":"$content_type",'
'"len":"$content_length",'
'"referer":"$http_referer",'
'"ua":"$http_user_agent",'
'"body":"$logged_body"'
'}';
access_log /var/log/nginx/payloads/payloads.log payloads;