August 2017
Intermediate to advanced
278 pages
8h 53m
English
In order to log POST data, we need to define a custom log format:
log_format post_logs '[$time_local] "$request" $status '
'$body_bytes_sent "$http_referer" '
'"$http_user_agent" [$request_body]';
By logging $request_body, we'll be able to see the contents of a POST submission.
To enable our POST log format, all we need to do is specify the log format for the access logs:
access_log /var/log/nginx/postdata-access.log post_logs;
If you just want to verify that it's working as expected, we can use cURL to send post data. I've used Express, as set up in Chapter 3, Common Frameworks, to accept the POST data, so we can make a call as follows:
curl http://express.nginxcookbook.com/ -d 'name=johnsmith,phone=123123,email=john@smith.demo' ...
Read now
Unlock full access