http模块的日志,可以使用普通变量和日志模块特有的变量
http://nginx.org/en/docs/http/ngx_http_log_module.html
nginx所有变量见索引文件:
http://nginx.org/en/docs/varindex.html
http核心模块变量:
http://nginx.org/en/docs/http/ngx_http_core_module.html#variables

样例:

http模块中:
log_format httplog ‘[$time_local][$status][$remote_addr]’
‘[rt:$request_time][$bytes_sent]’
‘[upa:$upstream_addr][uct:$upstream_connect_time][uht:$upstream_header_time][urt:$upstream_response_time]’
‘[$request][$http_referer][$http_user_agent]’;

upstream模块中:
log_format sshlog ‘[$time_local][$status][$remote_addr][$session_time]’
‘[$protocol][$bytes_sent][$bytes_received]’
‘[ua:$upstream_addr][uct:$upstream_connect_time]’;

记录特定的http header

header在nginx的变量为httpxxxx
如user-agent,就是$http_user_agent,官方文档这么描述:
$http__name

arbitrary request header field; the last part of a variable name is the field name converted to lower case with dashes replaced by underscores
某个特别字段Authorization,就是$httpauthorization
同理对于请求参数也可以用类似的方法获取,如$arg_name
$arg__name

argument name in the request line

image.png