Eric Guo's blog.cloud-mes.com

Hoping writing JS, Ruby & Rails and Go article, but fallback to DevOps note

Record the Post Body in Nginx Access Log

Permalink

Sometime, it is easier to debug the Rails program if nginx can record the user’s post body and here is how to.

server {
log_format postdata '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" '
'request_body:"$request_body"';
location @puma_rails_production {
client_body_buffer_size 16k;
client_max_body_size 4G;
access_log /var/www/oauth2id/shared/log/nginx.access.log postdata;
proxy_set_header X-Request-Body $request_body;
}
}

Warning: It’s not compatible with .NET apps, detail not yet check so recommand only enable during debug.

Comments