Today read the Old Boys Education blog http://oldboy.blog.51cto.com/ in a shell implementation of Nginx reverse proxy back end Realserver Health check of the article, According to one of the students Friends of the idea of writing a script.
nginx.conf part of the content is as follows:
Upstream Rs_pools {server 10.0.0.8:80 weight=5; Server 10.0.0.9:80 weight=5; Server 10.0.0.10:80 weight=5; } server {location/{Proxy_pass http://rs_pools; } }
Second, the script is as follows:
#!/bin/bashnginxconfigpath=/application/nginx/confnginxconfigfile=nginx.confnginxcheckpath=/application/nginx/ htmlnginxcheckfile=nginx_check.html# obtains the IP address of realserver via SED and awk, saving the rs_list= (' sed -n '/upstream/{:a; N;/}/!ba;p} ' ${NginxConfigPath}/${NginxConfigFile} | awk -F ' [ :]+ ' '/ SERVER/{PRINT&NBSP;$2} ") #生成html主体部分的上半部分 and generate the first row of the table function html_static () {cat >> ${ nginxcheckpath}/${nginxcheckfile}<<eofThe normal status effect is as follows:
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M00/8F/C7/wKiom1jsl_OyuwdaAAGB_xaH0gs764.jpg-wh_500x0-wm_ 3-wmp_4-s_85037917.jpg "style=" Float:none; "title=" nginx_up "alt=" Wkiom1jsl_oyuwdaaagb_xah0gs764.jpg-wh_50 "/>
Realserver Service Unavailable effect is as follows:
650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M00/8F/C7/wKiom1jsl_WiMZRJAAGW8KpRIQo312.jpg-wh_500x0-wm_ 3-wmp_4-s_2338108888.jpg "style=" Float:none; "title=" Nginx_down "alt=" wkiom1jsl_wimzrjaagw8kpriqo312.jpg-wh_50 "/ >
Hasty completion, there is the wrong place, please point out!!!
This article is from the "Lost in Linux" blog, please be sure to keep this source http://zihang.blog.51cto.com/158746/1914953
Analysis shell implement Nginx reverse proxy backend realserver Health Check