Nginx
安装与使用
# Centos7安装nginx
yum install epel-release -y
yum install nginx.x86_64 -y
常用命令
# 检查配置文件
nginx -t
# 重新加载配置文件
nginx -s reload
Nginx日志字段解析
| 字段名称 | Note |
|---|---|
| time_local | 时间戳 |
| remote_addr | 客户端地址 |
| remote_user | 客户端用户名称 |
| request | 请求的URI和协议 |
| request_method | http请求方法 |
| request_time | 整个请求时间 |
| request_length | 请求的长度 |
| status | http请求状态 |
| body_bytes_sent | 响应body字节数 |
| bytes_sent | 响应总字节数 |
| http_referer | referer信息 |
| http_user_agent | UA信息 |
| http_x_forwarded_for | 客户端IP |
| http_host | IP或域名(包括端口) |
| host | IP或域名(不包括端口) |
| upstream_addr | 后端提供服务的地址 |
| upstream_response_time | upstream响应时间 |
| upstream_status | upstream响应状态 |
| server_protocol | 服务器协议 |
| server_port | 服务器端口 |
| args | 请求参数 |
| response_header_data | 响应头数据 |
Nginx与Logstash直接传输数据
配置nginx.conf文件
log_format logstash escape=json '{"timestamp": "$time_local","**": "$**"}';
access_log syslog:server=xxx.xxx.xxx.xxx:xxx,nohostname,tag=nginx_access_log logstash;