nginx uses the third-party module nginx_upstream_check_module to check the health of the backend server

WBOY
Release: 2016-07-28 08:28:37
Original
1157 people have browsed it

Everyone knows that nginx did reverse generation in the previous period. If the back-end server goes down, nginx cannot put this real server upstream, so there will still be requests forwarded to the back-end real server, although nginx can localtion Enable proxy_next_upstream to solve the error page returned to the user. The method is: http://www.linuxyan.com/web-server/67.html. You can refer to it, but this will still forward the request to this server. , and then forward it to another server, which wastes one forwarding. This time, we use the nginx module nginx_upstream_check_module developed with the Taobao technical team to detect the health status of the rear realserver. If the backend server is unavailable, all requests will not be forwarded. to this server.
First go here to download the nginx module https://github.com/yaoweibin/nginx_upstream_check_module
The following is the installation of nginx with module patch

$ wget 'http://nginx.org/download/nginx-1.0.14.tar .gz'
$ tar -xzvf nginx-1.0.14.tar.gz
$ cd nginx-1.0.14/
$ patch -p1 < /path/to/nginx_http_upstream_check_module/check.patch
Note: due to nginx version Update, for nginx version 1.2 or above, the patch is check_1.2.1+.patch
$ ./configure –add-module=/path/to/nginx_http_upstream_check_module
$ make
$ in the nginx.conf configuration file after make install

Add health check to upstream as follows:
upstream linuxyan {
server 192.168.0.21:80;
server 192.168.0.22:80;
check interval=3000 rise=2 fall=5 timeout=1000;
}

Add here and below Let me explain this sentence. The interval detection interval is in milliseconds. If rsie requests 2 times normally, the status of the realserver will be marked as up. If fall indicates that the request fails 5 times, the status of the realserver will be marked as down. , timeout is the timeout time, the unit is milliseconds.
In the server segment, you can add a page to view the realserver status
location /nstatus {
check_status;
access_log off;
#allow SOME.IP.ADD.RESS;
#deny all;
}

Open the nstatus page at this time You can see the current status of the realserver,
as shown below:
1. When 2 realservers are normal
nginx uses the third-party module nginx_upstream_check_module to check the health of the backend server

2. When one realserver fails
nginx uses the third-party module nginx_upstream_check_module to check the health of the backend server


The above introduces how nginx uses the third-party module nginx_upstream_check_module to check the health of the back-end server, including the following aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!