As we all know, nginx acts as a reverse proxy in the early stage. 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 Proxy_next_upstream can be enabled in localtion to resolve error pages returned to the user.
But this will still forward the request to this server, and then forward it to other servers, thus wasting a forwarding. This time with the help of The nginx module, nginx_upstream_check_module, developed by the Taobao technical team, detects the health status of the back-end realserver. If the back-end server is unavailable, all requests will not be forwarded to this server.
Installation configuration
File list information
[root@iZ233438q9fZ upload]# ll drwxr-xr-x 6 ftpuser ftp 4096 Aug 19 10:04 nginx_upstream_check_module drwxr-xr-x 8 1001 1001 4096 Jun 16 2015 nginx-1.9.2.tar.gz
Unzip
[root@iZ233438q9fZ upload]# tar -zxvf nginx-1.9.2.tar.gz [root@iZ233438q9fZ upload]# cd nginx-1.9.2
nginx patch installation
[root@iZ233438q9fZ nginx-1.9.2]# patch -p0 <p><strong>Compilation configuration</strong></p><pre class="brush:php;toolbar:false">[root@iZ233438q9fZ nginx-1.9.2]# ./configure --add-module=/var/ftp/upload/nginx_upstream_check_module --prefix=/usr/local/server/nginx [root@iZ233438q9fZ nginx-1.9.2]# make && make install
nginx.conf health check configuration example
Parameter description:
- check_status: [html|csv|json], default html
- check_http_send: Specify the detected http access address, default /
- type: [tcp|http|ssl_hello|mysql|ajp], default tcp
- interval: health sent to the backend Interval for checking packets, unit (milliseconds)
- fall(fall_count): If the number of consecutive failures reaches fall_count, the server is considered down.
- rise(rise_count): If the number of consecutive successes reaches rise_count, the server is considered up.
- timeout: Timeout for backend health requests.
PS: If it keeps showing failure, please check whether there is index.jsp or index.html in the project root directory
For more Nginx related technical articles, please visit Nginx usage tutorial column for learning!
The above is the detailed content of Should I install nginx first and then add the health module?. For more information, please follow other related articles on the PHP Chinese website!