•修改配置文件fastcgi.conf,加上以下内容 fastcgi_param HTTP_USERNAME $http_username; •修改nginx.conf,日志输出格式,添加$http_username log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for" "$http_username"'; •重启nginx •输出结果 127.0.0.1 - - [11/Aug/2015:15:50:22 +0800] "GET /signin?ru=http://m.focus.cn/user/ HTTP/1.1" 200 4777 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.65 Safari/537.36" "-" "maso88" fastcgi fastcgi是快速通用网关接口的缩写,nginx的进程将请求通过unix domain socket(都位于同一物理服务器)或者一个IP Socket(FastCGI部署在其它物理服务器)传递给FastCGI进程,fastcgi处理完后返回给nginx进程 (责任编辑:IT) |