标签:nginx

LNMP:Nginx 平滑升级 tengine

安装 tengine 备份nginx配置文件:

wget -c http://tengine.taobao.org/download/tengine-2.2.0.tar.gz
tar zxvf tengine-2.2.0.tar.gz
cd tengine-2.2.0
./configure
make
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
cp -r objs/nginx /usr/local/nginx/sbin/nginx

vim /usr/local/nginx/conf/nginx.conf

删除如下代码:

location /status {

stub_status on;

access_log off;

}

检测是否正常:

/usr/local/nginx/sbin/nginx -t

提示“the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
configuration file /usr/local/nginx/conf/nginx.conf test is successful”为正常

重启nginx:

kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`
/etc/init.d/nginx stop
/etc/init.d/nginx start

查看nginx版本:

/usr/local/nginx/sbin/nginx -v

Nginx:过滤Pingback CC请求

写入 nginx.conf 过滤Pingback CC请求

if ($http_user_agent ~*
(ApacheBench|pingback|WordPress|MJ12bot|AhrefsBot|360JK|PHP|php|Jorgee)
) {return 101;} if ($http_user_agent = “” ) {return 101;} if (
$request = “POST /reg.html HTTP/1.1” ) {return 400;} if ( $request =
“POST / HTTP/1.1” ) {return 400;} if ( $request = “POST / HTTP/1.0” )
{return 400;} if ( $request = “POST // HTTP/1.0” ) {return 400;}