nginx记录POST数据

一、准备安装包
wget http://luajit.org/download/LuaJIT-2.0.5.tar.gz
需要下载另外一个包,在github上
通过浏览器下载:
http://github.com/simpl/ngx_devel_kit/tags
http://github.com/chaoslawful/lua-nginx-module/tags
下载OpenResty源码,编译和安装

最重要的是需要有nginx包

二、开始安装
2.1安装LuaJIT
[root@hadoop src]# tar -zxvf LuaJIT-2.0.5.tar.gz
[root@hadoop src]# cd LuaJIT-2.0.5
[root@hadoop LuaJIT-2.0.5]# make
[root@hadoop LuaJIT-2.0.5]# make install
记住安装位置(比如):
==== Successfully installed LuaJIT 2.0.5 to /usr/local ====
位置:/usr/local

2.2 解压其余两个包
解压ngx_devel_kit与lua-nginx-module到/data目录下:
/data/ngx_devel_kit-0.3.1
/data/lua-nginx-module-0.10.16rc5

2.3 重新编译nginx

cd nginx-1.17.0/
export LUAJIT_LIB=/usr/local/lib   #前面需要记住的lib
export LUAJIT_INC=/usr/local/include/luajit-2.1
./configure --prefix=/usr/local/nginx --add-module=/data/ngx_devel_kit-0.3.1 --add-module=/data/lua-nginx-module-0.10.16rc5  --with-http_stub_status_module --with-http_ssl_module
#如果开启了SSL模块,不要忘记添加回去

注意:ubuntu下安装可能会出现下面错误:
checking for PCRE library ... not found
checking for PCRE library in /usr/local/ ... not found
checking for PCRE library in /usr/include/pcre/ ... not found
checking for PCRE library in /usr/pkg/ ... not found
checking for PCRE library in /opt/local/ ... not found
checking for OpenSSL library ... not found
checking for OpenSSL library in /usr/local/ ... not found
checking for OpenSSL library in /usr/pkg/ ... not found
checking for OpenSSL library in /opt/local/ ... not found
checking for zlib library ... not found

=================================
解决方法:
apt-get install libpcre3-dev
sudo apt-get install libssl-dev
sudo apt-get install zlib1g-dev  
centos系统解决方案另行搜索,方法大同小异(zlib、zlib-devel、openssl、openssl-devel、prce、prce-devel)

然后:
make&&make install

#重启nginx
cd /usr/local/nginx/sbin/
sudo ./nginx -t

这个方法成功率不高,太麻烦。不如直接用openResty
# [openresty 实现记录http response](http://www.fblinux.com/?p=1397)
openResty中获取请求 body [http://www.hangdaowangluo.com/archives/2746](http://www.hangdaowangluo.com/archives/2746)
几篇好文 
[https://www.jianshu.com/p/78853c58a225](https://www.jianshu.com/p/78853c58a225)
[https://www.codercto.com/a/44622.html](https://www.codercto.com/a/44622.html)
[http://www.fblinux.com/?p=1397](http://www.fblinux.com/?p=1397)


你可能感兴趣的:(nginx记录POST数据)