标签:nginx配置文件 remote user listen com 转换 虚拟主机 允许 $1
1 .基于rewrite实现全站httpslog_format json ‘{"@timestamp":"$time_iso8601",‘
‘"@version":"1",‘
‘"client":"$remote_addr",‘
‘"url":"$uri",‘
‘"status":"$status",‘
‘"domain":"$host",‘
‘"host":"$server_addr",‘
‘"size":"$body_bytes_sent",‘
‘"responsentime":"$request_time",‘
‘"referer":"$http_referer",‘
‘"useragent":"$http_user_agent",‘
‘"upstreampstatus":"$upstream_status",‘
‘"upstreamaddr":"$upstream_addr",‘
‘"upstreamresponsetime":"$upstream_response_time"‘
‘}‘;
access_log logs/access_json.log json;
#将以上内容添加到nginx配置文件的http区块123456789101112131415161718
2>、输入的日志格式如下:
{"@timestamp":"2019-03-16T00:44:07+08:00","@version":"1","client":"192.168.1.X","url":"-","status":"400","domain":"localhost","host":"192.168.1.x","size":"166","responsentime":"0.286","referer":"-","useragent":"-","upstreampstatus":"-","upstreamaddr":"-","upstreamresponsetime":"-"}br/>{"@timestamp":"2019-03-16T22:02:29+08:00","@version":"1","client":"192.168.1.x","url":"-","status":"400","domain":"localhost","host":"192.168.1.x","size":"166","responsentime":"0.205","referer":"-","useragent":"-","upstreampstatus":"-","upstreamaddr":"-","upstreamresponsetime":"-"}
{"@timestamp":"2019-03-16T22:02:29+08:00","@version":"1","client":"192.168.1.x","url":"-","status":"400","domain":"localhost","host":"192.168.1.x","size":"166","responsentime":"0.218","referer":"-","useragent":"-","upstreampstatus":"-","upstreamaddr":"-","upstreamresponsetime":"-"}123
3>、输出的json格式为:
{
"@timestamp": "2019-03-16T22:02:29+08:00",
"@version": "1",
"client": "192.168.1.x",
"url": "-",
"status": "400",
"domain": "localhost",
"host": "192.168.1.x",
"size": "166",
"responsentime": "0.218",
"referer": "-",
"useragent": "-",
"upstreampstatus": "-",
"upstreamaddr": "-",
"upstreamresponsetime": "-"
}
3.基于location实现将访问web的请求转发至后端apache服务器,最好实现cache功能
标签:nginx配置文件 remote user listen com 转换 虚拟主机 允许 $1
原文地址:https://blog.51cto.com/14127448/2364343