nginx 访问日志 access.log 添加设置cookie记录
时间:2016-02-22 19:50 来源:linux.it.net.cn 作者:IT
需求,把cookie记录到访问日志里,供数据挖掘部门统计用户行为。 nginx 配置文件添加如下,这是虚拟主机的配置
server
{
# 在server块添加以下代码
# 设置默认值
set $uid "-";
# 存在值则赋值
if ( $http_cookie ~* "at_uvid=(\S+)(;.*|$)"){
set $uid $1;
}
# 最后一段数据是该cookie值
log_format uid_log '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" "$uid"';
access_log /var/log/nginx/gretheer.com.log uid_log;
#到此结束
}
(责任编辑:IT)
需求,把cookie记录到访问日志里,供数据挖掘部门统计用户行为。 nginx 配置文件添加如下,这是虚拟主机的配置
(责任编辑:IT) |