创建 apps/status.passwd 文件,创建方法(用户设为test,密码设为tengine)
代码语言:javascript复制[root@i-1avyrt2d apps]# perl -e 'print crypt(tengine,tengine)';
tejMqaZALnkgk[root@i-1avyrt2d apps]# vim status.passwd
[root@i-1avyrt2d apps]# cat status.passwd
test:tejMqaZALnkgk
[root@i-1avyrt2d apps]#
下面代码的作用就是可以使用 http://ip/status 监控后端服务器的状态
代码语言:javascript复制 location /status {
auth_basic "input your name and passsword";
auth_basic_user_file apps/status.passwd;
check_status;
access_log off;
allow all;
}
代码语言:javascript复制Tip: 在启动前可以使用 nginx check 一下配置语法
[root@i-1avyrt2d conf]# ../sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@i-1avyrt2d conf]# kill -HUP `cat ../logs/nginx.pid `
[root@i-1avyrt2d conf]#
使用浏览器访问 http://103.21.118.104/
使用浏览器访问 http://103.21.118.104/status
认证成功后 (test:tengine)
命令汇总
wget http://tengine.taobao.org/download/tengine-2.1.1.tar.gz
md5sum tengine-2.1.1.tar.gz
tar -zxvf tengine-2.1.1.tar.gz
./configure
make
make install
echo $?
sbin/nginx -t -c conf/nginx.conf
sbin/nginx -c conf/nginx.conf
/usr/local/nginx/sbin/nginx -h
/usr/local/nginx/sbin/nginx -m
/usr/local/nginx/sbin/nginx -m 2>&1 | grep upstream
/usr/local/nginx/sbin/nginx -m 2>&1 | grep upstream | grep check
sbin/nginx -h
sbin/nginx -v
sbin/nginx -V
ll /usr/local/nginx
ll /usr/local/nginx.old/
cat nginx.conf | grep -v "#" | grep -v "^$"
cat apps/proxy_tengine.conf | grep -v "#" | grep -v "^$"
../sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
kill -HUP
cat ../logs/nginx.pid ``perl -e 'print crypt(tengine,tengine)';
cat status.passwd
../sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
原文地址