Nginx compiles Taobao health check module

1. Download the module package

wget https://codeload.github.com/yaoweibin/nginx_upstream_check_module/zip/master
unzip master

2. Patch

patch -p1 <../nginx_upstream_check_module-master/check_1.16.1+.patch // choose your own version
Add --add-module=../nginx_upstream_check_module-master/ to the original compilation parameters to compile
make //Execute make after completion, just execute make
cp ./objs/nginx /usr/local/nginx/sbin/ //overwrite the original executable file
/usr/local/nginx/sbin/nginx -t //Check if there is a problem

3. Increase health check

upstream name {
       server 192.168.0.21:80;
       server 192.168.0.22:80;
       check interval=3000 rise=2 fall=5 timeout=1000 type=http;
        
}
-interval: The interval of health check packets sent to the backend.
    -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 timeout period of the back-end health request.
    -default_down: Set the initial state of the server. If it is true, it means that it is down by default; if it is false, it is up. The default value is true, that is, the server considers it to be unavailable at first, and it will be considered healthy only after the health check package reaches a certain number of successes.
    -type: the type of health check package, now supports the following multiple types
        -tcp: simple tcp connection, if the connection is successful, the backend is normal.
        -ssl_hello: Send an initial SSL hello packet and accept the server's SSL hello packet.
        -http: Send an HTTP request, and judge whether the backend is alive by the status of the backend's reply packet.
        -mysql: Connect to the mysql server and judge whether the backend is alive by receiving the greeting packet from the server.
        -ajp: Send a Cping packet of the AJP protocol to the backend, and judge whether the backend is alive by receiving the Cpong packet.
    -port: Specify the check port of the back-end server. You can specify the port of the back-end server that is different from the real service. For example, the back-end provides an application on port 443. You can check the status of port 80 to determine the health of the back-end. The default is 0, which means the same port as the real service provided by the backend server. This option appears in Tengine-1.4.0.

This article is only used to record knowledge points, reference: https://www.cnblogs.com/larry-luo/p/10619397.html

Guess you like

Origin blog.51cto.com/9605182/2546255