Methods Nginx correctly record the post log

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

Methods Nginx correctly record the post log

In fact very simple, it depends on the access_log on which the location inside.

One, to contain fastcgi_pass or proxy_pass Location.
The following:
location ~ \.php$ {
 root           /data/webapps;
 fastcgi_index  index.php;
 fastcgi_param  SCRIPT_FILENAME  /data/webapps$fastcgi_script_name;

 access_log post_log /tmp/post.log

Post_log HTTP region which define the log type, can be so:
log_format post_log '$remote_addr - $request_body';

$Request_body is the post data.

Then the post data to this directory of the.Php file, you can record the post log.

Two, to any Location.

The specific steps are as follows:
1, Install LuaJIT
tar -zxvf LuaJIT-2.0.1.tar.gz
make PREFIX=/data/apps/luajit2.0.1
make install PREFIX=/data/apps/luajit2.0.
2, Download and unzip the following two modules
The 2 directory after decompression were moved to the /usr/local/src/ directory (personal habit)
3, To compile Nginx
export LUAJIT_LIB=/data/apps/luajit2.0.1/lib
export LUAJIT_INC=/data/apps/luajit2.0.1/include/luajit-2.0
./configure --prefix=/data/apps/nginx --add-module=/usr/local/src/ngx_devel_kit-0.2.19 --add-module=/usr/local/src/lua-nginx-module-0.9.2
make -j2
make install
4, Then the following statements in the need to record post log Location plus:
lua_need_request_body on;
content_by_lua 'local s = ngx.var.request_body';
log_format post_log '$remote_addr - $request_body';

5, When starting Nginx if error:
error while loading shared libraries: cannot open shared object file: No such file or directory
ln -s /data/apps/luajit2.0.1/lib/ /lib64/

Reference document
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Dick at January 17, 2014 - 8:24 AM