Nginx uptream health check
Upstream hello {
Server 100.14.1.3:1201
Server 100.14.1.4:1201
Check interval=3000 rise=2 fall=5 timeout=1000 type=http
Check_http_send "HEAD / product HTTP/1.0\ r\ n\ r\ n"
Check_http_expect_alive http_2xx http_3xx
}
Server {
Listen 80
Server_name hello.youbest.com
Access_log / data/logs/nginx/hello.youbest.com.access.log main
Location / {
Proxy_set_header X-Forwarded-For $remote_addr
Proxy_set_header X-Real-IP $remote_addr
Proxy_pass http://hello;
}
}
First, confirm whether the service type is http or tcp.
Check interval=3000 rise=2 fall=5 timeout=1000 type=http; or check interval=3000 rise=2 fall=5 timeout=1000 type=tcp; then confirms whether the url of the health check supports HEAD requests or GET requests [root@100-14-1-3] # curl-v-XHEAD http://hello.youbest.com/productAbout to connect () to hello.youbest.com port 80 (# 0) Trying 10.24.1.3. ConnectedConnected to hello.youbest.com (100.14.1.3) port 80 (# 0)
HEAD / HTTP/1.1
User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh3/1.4.2
Host: baidu.com
Accept: /
< HTTP/1.1 200 OK
< Date: Tue, 07 Jan 2020 08:29:28 GMT
< Server: Apache
< Last-Modified: Tue, 12 Jan 2010 13:48:00 GMT
< ETag: "51-47cf7e6ee8400"
< Accept-Ranges: bytes
< Content-Length: 81
< Cache-Control: max-age=86400
< Expires: Wed, 08 Jan 2020 08:29:28 GMT
< Connection: Keep-Alive
< Content-Type: text/html