rsyslog收集nginx日志配置
# tar -xzf nginx-1.4.7.tar.gz# cd nginx-1.4.7
# ./configure --user=www --group=www --prefix=/usr/local/nginx \
--with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module \
--with-pcre=/root/pcre-8.35 --with-http_realip_module --with-http_image_filter_module #这个是测试,我是把pcre-8.35解压到root目录
# make
# make install
#以上是安装nginx的步骤,下面打补丁
# git clone https://github.com/splitice/nginx_syslog_patch
# patch -p1 < /root/nginx-1.4.7/nginx_syslog_patch/syslog-1.4.0.patch
patching file src/core/ngx_cycle.c
patching file src/core/ngx_log.c
patching file src/core/ngx_log.h
patching file src/http/modules/ngx_http_log_module.c
patching file src/http/ngx_http_core_module.c
Hunk #2 succeeded at 4895 (offset 2 lines).
Hunk #3 succeeded at 4913 (offset 2 lines).
Hunk #4 succeeded at 4952 (offset 2 lines).
patching file src/http/ngx_http_request.c
Hunk #1 succeeded at 517 (offset -14 lines).
Hunk #2 succeeded at 798 (offset -23 lines).
Hunk #3 succeeded at 2002 (offset -23 lines).
# ./configure --user=www --group=www --prefix=/usr/local/nginx \
--with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module \
--with-pcre=/root/pcre-8.35 --with-http_realip_module --with-http_image_filter_module \
--add-module=/root/nginx-1.4.7/nginx_syslog_patch/
# make
# make install
# /usr/local/nginx/sbin/nginx -V #查看编译的配置参数
nginx version: nginx/1.4.7
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)
TLS SNI support enabled
configure arguments: --user=www --group=www --prefix=/usr/local/nginx \
--with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module \
--with-pcre=/root/pcre-8.35 --with-http_realip_module --with-http_image_filter_module \
--add-module=/root/nginx-1.4.7/nginx_syslog_patch/
# grep -v ^.*# /usr/local/nginx/conf/nginx.conf|sed '/^$/d'#nginx配置
worker_processes1;
syslog local6 nginx;
events {
worker_connections1024;
}
http {
include mime.types;
default_typeapplication/octet-stream;
log_formatmain'$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
sendfile on;
keepalive_timeout65;
server {
listen 80;
server_namelocalhost;
index index.html;
root /var/www;
access_logsyslog:notice|logs/host1.access.log main;
error_log syslog:notice|logs/host1.error.log;
error_page 500 502 503 504/50x.html;
location = /50x.html {
root html;
}
}
}
页:
[1]