參考:https://github.com/yaoweibin/nginx_upstream_check_module
注:要根據之前編譯來重新編譯。
下載healthcheck_nginx_upstreams:見附件。
unzip nginx_upstream_check_module-master.zip
這裏要注意下,用回源nginx-1.2.6包,否則會出錯。也就是確定之前沒有patch過源包
patch -p1 < ../nginx_upstream_check_module-master/check_1.2.6+.patch
make
make install
service nginx start
vi /etc/nginx/nginx.conf
在負載服務器下加入
check interval=3000 rise=2 fall=5 timeout=1000;
在server中加入
location /status {
check_status;
access_log off;
allow 10.1.230.35;
deny all;
}
service nginx restart
打開http://IP/status
會看到後端服務器的運行狀態。