nginx日志中记录post数据
来源:互联网 发布:sql如何导入数据库 编辑:程序博客网 时间:2024/06/11 16:33
nginx记录post数据,需要安装lua-nginx-module模块
1、下载luajit: http://luajit.org/download.html
make prefix=/usr/local/luajit
make install prefix=/usr/local/luajit
2、下载ngx_devel_kit模块
https://github.com/simpl/ngx_devel_kit/
解压到 /usr/local/src/ngx_devel_kit
3、下载lua-nginx-module模块
https://github.com/openresty/lua-nginx-module
解压到 /usr/local/src/lua_nginx_module
4、添加环境变量
exportLUAJIT_LIB=/usr/local/luajit/lib
exportLUAJIT_INC=/usr/local/luajit/include/luajit-2.0
5、nginx 编译
--user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-ipv6 --with-http_sub_module --with-openssl=/root/lnmp1.4-full/src/openssl-1.0.2l --add-module=/usr/local/src/ngx_devel_kit --add-module=/usr/local/src/lua-nginx-module
6、添加共享库
echo "/usr/local/luajit/lib" >> /etc/ld.so.conf
ldconfig
7、配置nginx
在location /{}中添加
lua_need_request_body on; content_by_lua_block { ngx.req.read_body() local args, err = ngx.req.get_post_args(),ngstr, if not args then ngx.say("failed to get post args: ", err) return end for key, val in pairs(args) do if type(val) == "table" then ngstr = '$ngstr - ngx.say(key, ": ", table.concat(val, ", "))' else ngstr = '$ngstr - ngx.say(key, ": ", val)' end $request_body = ngstr end }
开启log access_log /home/wwwlogs/XXX.log main;
http 中配置日志格式
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent $request_body "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';
- nginx日志中记录post数据
- nginx把post的数据记录到日志中
- nginx接受post数据,并在日志里记录数据
- nginx单独添加模块|日志记录post数据
- Nginx记录post请求数据
- 让nginx日志支持记录POST请求
- Nginx正确记录post日志的方法
- nginx日志记录post的参数
- nginx记录响应与POST请求日志
- 在nginx日志的access log中记录post请求的参数值
- nginx日志记录请求和响应数据
- nginx日志记录切割
- nginx查看post请求日志
- nginx日志数据提取
- Nginx 记录请求分发日志
- 自定义nginx日志记录格式
- Nginx 记录请求分发日志
- [nginx]如何在access log中记录post请求的参数
- 【转】Java 9 新特性汇总
- 微信小程序 关闭调试模式后显示加载中
- 详解SVN 的使用
- IDE搭建JFinal环境
- Python3 JSON 数据解析
- nginx日志中记录post数据
- linux contab 易错搞混设置时间
- python 在pycharm中 爬虫
- Hibernate 存储 中文乱码
- 微信网页授权
- CentOS6与CentOS7的差异对比
- html5之点击按钮3秒不能点击
- POJ 2488.A Knight's Journey
- Python 一个服务器监听多个客户端请求