Analysis shell implement Nginx reverse proxy backend realserver Health Check

Source: Internet
Author: User
Tags nginx reverse proxy

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}<<eof

The 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.