Complete the code to define a basic HTTP health check location in nginx.
location /healthz {
return [1];
}The return 200; directive sends a simple HTTP 200 OK response, which is commonly used for health checks.
Complete the code to enable active health checks for an upstream server in nginx.
upstream backend {
server backend1.example.com;
[1];
}check_health or active_check.The health_check; directive enables active health checks on the upstream servers.
Fix the error in the health check configuration by completing the directive correctly.
server {
location /health {
proxy_pass http://backend;
proxy_next_upstream [1];
}
}The proxy_next_upstream off; directive disables retrying the next upstream server on failure, which is often desired for health check endpoints to get accurate status.
Fill both blanks to configure a passive health check that marks a server down after 3 failures.
upstream backend {
server backend1.example.com max_fails=[1] fail_timeout=[2];
}max_fails=3 means the server is marked down after 3 failed attempts. fail_timeout=10s sets the time period to consider those failures.
Fill all three blanks to configure an HTTP health check with interval, timeout, and HTTP status match.
health_check interval=[1] timeout=[2] rise=2 fall=5 http_statuses=[3];
The interval=5s sets how often to check. timeout=2s sets how long to wait for a response. http_statuses=200-299 defines which HTTP codes mean healthy.