POST request body manipulation

pumbac nginx-forum at nginx.us
Thu Dec 17 23:36:35 UTC 2015


in my case, I can log the $request_body in the access_log via proxy_pass, 
even when uploading files more then 1MB. 

I just wanted to limit the size of the $request_body in the log. Here is my
nginx.conf:

http {
    include       mime.types;
    default_type  application/octet-stream;

    map $request_body $request_body_short {
        "~^(?<SHORT>.*filename.*)Content-Type" $SHORT;
        default $request_body;
    }

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request"
'
        '$status $body_bytes_sent "$http_referer" "$http_user_agent"
"$http_x_forwarded_for" $request_time '
        '"$request_body_short" $http_uid "$http_build" "$http_appversion"
"$uid_got" "$host"';

    access_log  logs/access.log  main;

    ....
}

if I changed the map default value to something like 'wrong', the logged
$request_body would be 'wrong'.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,258335,263535#msg-263535



More information about the nginx mailing list