http://ju.outofmemory.cn/entry/105503
需求,把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;#到此结束}
本文介绍了如何在nginx的access.log中记录cookie信息,以满足数据挖掘部门对用户行为统计的需求。只需在虚拟主机的nginx配置文件中进行相应设置。
505

被折叠的 条评论
为什么被折叠?



