nginx添加模块ngx_log_if-master

先下载模块https://github.com/cfsego/ngx_log_if到目录/usr/local/ningx,解压缩
查看之前安装的参数:
# /usr/local/nginx/sbin/nginx -V
再到以前安装nginx的源文件目录
# cd /root/nginx-1.6.0;
# ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-pcre --with-http_realip_module --add-module=/usr/local/nginx/substitutions4nginx-read-only --add-module=/usr/local/nginx/ngx_log_if-master
# make;
替换之前的nginx执行文件
# service nginx stop;mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx-sbin-backup;cp /root/nginx-1.6.0/objs/nginx /usr/local/nginx/sbin/nginx; service nginx start

在nginx.conf文件里添加:
access_log_bypass_if ($uri = '/img404.jpg');
access_log_bypass_if ($status = 302);
另外:需要把/usr/local/nginx 和其他的所有缓存目录,权限更改为www:www

打赏