"Turn" nginx proactive back-end server Health Check

Source: Internet
Author: User

Original link http://tengine.taobao.org/document_cn/http_upstream_check_cn.html

Ngx_http_upstream_check_module This module provides proactive back-end server Health check functionality for Tengine. The module is Tengine-1.4. version 0 was not previously enabled by default, it can be turned on when configuring the Compile option:./configure--with-Http_upstream_check_moduleexampleshttp {Upstream Cluster1 {# simple round-Robin Server192.168.0.1: the; Server192.168.0.2: the; Check interval= theRise=2Fall=5timeout= +Type=http; Check_http_send"head/http/1.0\r\n\r\n";    Check_http_expect_alive http_2xx http_3xx; } upstream Cluster2 {# simple round-Robin Server192.168.0.3: the; Server192.168.0.4: the; Check interval= theRise=2Fall=5timeout= +Type=http; Check_keepalive_requests -; Check_http_send"head/http/1.1\r\nconnection:keep-alive\r\n\r\n";    Check_http_expect_alive http_2xx http_3xx; } Server {Listen the; Location/1{proxy_pass http://Cluster1;} Location/2{proxy_pass http://Cluster2;} Location/status {check_status;            Access_log off; Allow SOME. Ip. ADD.            RESS;        Deny all; }}} directive Syntax:check interval=milliseconds [Fall=count] [Rise=count] [timeout=milliseconds] [default_down=true|false] [TYPE=TCP|HTTP|SSL_HELLO|MYSQL|AJP] [port=Check_port] Default: If there are no configuration parameters, the defaults are: Interval=30000Fall=5Rise=2timeout= +default_down=trueType=tcpcontext:upstream This instruction can open the Health check function of the backend server. The parameter meaning behind the directive is: interval: The interval of the health check packets sent to the back end. 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: The time-out for the backend health request. Default_down: Set the initial state of the server, if true, it means that the default is down, if false, is up. The default value is true, that is, the start of the server is not available, it will be considered healthy after the health check pack has reached a certain number of successes. Type: The types of health check packages now support the following multiple types of TCP: Simple TCP connection, if the connection is successful, it means that the backend is OK. Ssl_hello: Send an initial SSL Hello packet and accept the server's SSL Hello package. http: Sends an HTTP request to determine whether the backend is alive by the state of the backend's reply packet. MySQL: Connect to the MySQL server to determine if the backend is alive by receiving the greeting packet from the server. AJP: Sends the cping packet of the AJP protocol to the back end to determine if the backend is alive by receiving the Cpong packet. Port: Specifies the check port for the back-end server. You can specify the port of a backend server that is different from the real service, such as a 443 port application on the backend, and you can check the status of Port 80 to determine the backend health. The default is 0, which means that the backend server provides the same port as the real service. This option appears on the Tengine-1.4.0. Syntax:check_keepalive_requests Request_numdefault:1context:upstream This directive configures the number of requests sent by a connection, with a default value of 1, which means that tengine closes the connection after 1 requests have been completed. Syntax:check_http_send Http_packetdefault:"get/http/1.0\r\n\r\n"context:upstream This directive configures the request content sent by the HTTP Health check package. To reduce the amount of data transmitted, it is recommended to use"HEAD"method. When using a long connection for health checks, add keep to the directive-alive request headers, such as:"head/http/1.1\r\nconnection:keep-alive\r\n\r\n"。 At the same time, the adoption"GET"method, the size of the request URI should not be too large to ensure that it can be transferred within 1 interval, otherwise it will be considered a backend server or network exception by the Health Check module. syntax:check_http_expect_alive [Http_2xx| http_3xx | http_4xx |Http_5xx] Default:http_2xx|http_3xxcontext:upstream This directive specifies the success status of the HTTP reply, which is considered healthy by default for the 2XX and 3XX states. Syntax:check_shm_size sizedefault:1mcontext:http All back-end server Health check states are stored in shared memory, which can set the size of shared memory. The default is 1M, and if you have more than 1000 servers and there are errors when configured, you may need to enlarge the size of the memory. syntax:check_status [HTML|csv|JSON] Default:check_status Htmlcontext:location Displays the health status page of the server. This directive needs to be configured in an HTTP block. In Tengine-1.4after 0, you can configure the format of the display page. Supported formats are: HTML, CSV, JSON. The default type is HTML. You can also specify the format using the requested parameters, assuming '/Status ' is the URL of your status page, and the format parameter changes the formatting of the page, such as:/status?format=HTML/status?format=CSV/status?format=JSON You can also use the status parameter to get a list of the same server states, such as:/status?format=html&status= Down/status?format=csv&status=up Below is an example of an HTML status page (server number is the amount of back-end servers, generation the number of Nginx reload. Index is the server, upstream is the name of the upstream in the configuration, and name is the server ip,status is the state of the server, rise is the number of successive checks of the server, fall is the number of consecutive check failures, check Type is the way to check that the check port is the port specifically set for health check on the back end):<! DOCTYPE HTML Public"-//W3C//DTD XHTML 1.0 strict//en"HTTP://WWW.W3.ORG/TR/XHTML1/DTD/XHTML1-STRICT.DTD">"http://www.w3.org/1999/xhtml">1, Generation:3"Background-color:white"cellspacing="0"cellpadding="3"Border="1"> <tr bgcolor="#C0C0C0"> <th>Index</th> <th>Upstream</th> <th>Name</th> <th>Status</th> <th>rise counts</th> <th>fall counts</th&            Gt            <th>check type</th> <th>check port</th> </tr> <tr> <td>0</td> <td>backend</td> <td>106.187.48.116: the</td> <td>up</td> <td> the</td> <td>0</td> <td>http</td> <td> the</td> </tr> </table></body>The following is an example of a CSV format page:0, Backend,106.187.48.116: the, Up, $,0, HTTP, theThe following is an example of a JSON-formatted page: {"Servers": {  " Total":1,  "Generation":3,  "Server": [   {"Index":0,"Upstream":"Backend","name":"106.187.48.116:80","Status":" up","Rise": -,"Fall":0,"type":"http","Port": the}  ] }}

"Turn" nginx proactive back-end server Health Check

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.