[日常] nginx记录post数据
1.使用log_format指令来更改日志格式,该指令只能放在http{}段
log_format 日志名 '日志内容';
server {
access_log /var/log/nginx/default.access.log 日志名;
}
2.$request_body是nginx的内置变量,可以记录post的数据
3.测试
log_format my_test_log escape=json '$request_filename $http_x_forwarded_for $fastcgi_script_name $document_root $request_body';
server {
access_log /var/log/nginx/default.access.log my_test_log;
}
4.其他nginx内置变量
$time_local 格式化的时间
$request 请求地址
$status 响应码
$body_bytes_sent 传送页面的字节数
$http_referer 来源地址
$http_user_agent 客户端UA
$document_root 当前文件的目录绝对地址,比如:/var/www/html
$fastcgi_script_name 当前url的绝对地址,比如:/info.php
$request_filename 当前请求文件的绝对物理地址,基于root和alias指令,比如:/var/www/html/info.php
$http_cookie cookie信息,这个也很重要,如果在cookie中带上了用户的标识,比较方便调试

[日常] nginx记录post数据的更多相关文章
- nginx记录post数据日志
1.vi nginx.conf 找到http {}中log_foramt ,定义post 日志格式 #log_format main '$remote_addr - $remote_user [$ti ...
- 解决nginx在记录post数据时 中文字符转成16进制的问题【转载】
1. 问题描述 nginx 在获取post数据时候,如果是中文,则转换成16进制显示在日志文件中,如下图所示. Paste_Image.png 日志格式为: log_format postdata ...
- Nginx 日志记录post数据,并使用goaccess进行日志分析
nginx日志默认不会记录post数据 在nginx配置文件的http节 log_format 日志格式标识 [escape=json] 日志格式 比如:日志格式标识设置为main,添加escape= ...
- Nginx记录-Nginx基础(转载)
1.Nginx常用功能 1.Http代理,反向代理:作为web服务器最常用的功能之一,尤其是反向代理. Nginx在做反向代理时,提供性能稳定,并且能够提供配置灵活的转发功能.Nginx可以根据不同的 ...
- 菜鸟nginx源代码剖析数据结构篇(六) 哈希表 ngx_hash_t(上)
菜鸟nginx源代码剖析数据结构篇(六) 哈希表 ngx_hash_t(上) Author:Echo Chen(陈斌) Email:chenb19870707@gmail.com Blog:Blog. ...
- 使用sharepreferce记录数组数据
使用sharepreferce记录数组数据 /** * * sharepreference纪录news数据 * * */ private static final String name=" ...
- nginx记录响应与POST请求日志
生产环境中的某些api出现故障,但是问题无法重现,但是又很想解决掉问题以及我们新项目上线,需要跟踪请求与响应的信息,可以预先找到一些bug,减少大面积的损失. 安装nginx与ngx_lua 响应日志 ...
- 菜鸟nginx源代码剖析数据结构篇(一)动态数组ngx_array_t
菜鸟nginx源代码剖析数据结构篇(一)动态数组ngx_array_t Author:Echo Chen(陈斌) Email:chenb19870707@gmail.com Blog:Blog.csd ...
- 新秀nginx源代码分析数据结构篇(四)红黑树ngx_rbtree_t
新秀nginx源代码分析数据结构篇(四)红黑树ngx_rbtree_t Author:Echo Chen(陈斌) Email:chenb19870707@gmail.com Blog:Blog.csd ...
随机推荐
- [LeetCode] Rectangle Overlap 矩形重叠
A rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) are the coordinates of its bot ...
- 4.DHCP与PRE
如何配置IP地址 使用net-tools $ sudo ifconfig eth1 10.0.0.1/24 $ sudo ifconfig eth1 up 使用Iproute2 ...
- 怎么过滤
replace(str, " ", ""); 就是这么简单
- 长沙学院APP之校园模块设计
一.简单回顾 在上次的scrum冲刺中,我将整个长沙学院的APP做了一个基本的架构设计以及框架设计,确定好了APP的功能结构以及实现时所要达到的效果,并且做了一个简单的用户登录界面,由于所学知识有限, ...
- SUSE12Sp3-.NET Core 2.2.1 runtime安装
1.安装libicu依赖 1.在线安装 sudo mkdir /usr/local/dotnet #创建目录 cd /usr/local/dotnet sudo wget https://downlo ...
- ansible基础-playbooks
1. playbooks介绍 如果说ansible的modules是工具,inventory配置文件是原材料,那么playbook就是一封说明书,这里会记录任务是如何如何执行的,当然如果你愿意,这里也 ...
- [SQL]LeetCode177. 第N高的薪水 | Nth Highest Salary
Write a SQL query to get the nth highest salary from the Employee table. +----+--------+ | Id | Sala ...
- [Swift]LeetCode698. 划分为k个相等的子集 | Partition to K Equal Sum Subsets
Given an array of integers nums and a positive integer k, find whether it's possible to divide this ...
- admui框架使用经验
刚开始接触admui框架时确实有些迷茫,不知道怎么使用,摸索了一段时间后才发现这个框架很简单!以下是我遇见的一些坑,总结一下啦! 1.使用框架第一步就是开启服务器,我给公司写项目时开启的是5000端口 ...
- PyCharm无法激活
如果你激活软件遇到问题 (Pycharm.GoLand.idea.phpstorm.webstorm.sublime.ultraEdit.win10等等) 比如: 激活框提示Key is invali ...