A health check is a process where NGINX regularly tests backend servers to see if they are working properly before sending traffic to them.
Click to reveal answer
beginner
How does NGINX decide to stop sending traffic to a backend server?
NGINX stops sending traffic to a backend server if the health check fails, meaning the server did not respond correctly or on time.
Click to reveal answer
intermediate
Which NGINX directive is used to enable active health checks?
The directive 'health_check' inside the 'upstream' block enables active health checks in NGINX Plus.
Click to reveal answer
intermediate
What is the difference between active and passive health checks in NGINX?
Active health checks send regular test requests to servers. Passive health checks watch real traffic and mark servers unhealthy if errors happen.
Click to reveal answer
intermediate
Write a simple NGINX upstream block with a health check enabled for two backend servers.
upstream backend {
server backend1.example.com;
server backend2.example.com;
health_check;
}
Click to reveal answer
What happens if a backend server fails a health check in NGINX?
ANGINX stops sending traffic to that server.
BNGINX restarts the server automatically.
CNGINX sends more traffic to that server.
DNGINX ignores the failure and continues.
✗ Incorrect
If a backend server fails a health check, NGINX marks it as unhealthy and stops sending traffic to it.
Which NGINX version supports active health checks natively?
ANGINX Open Source
BNGINX Plus
CBoth versions
DNeither version
✗ Incorrect
Active health checks are a feature of NGINX Plus, the commercial version.
What type of request does an active health check usually send?
AA special test request like HTTP GET to a health endpoint
BA normal user request
CA database query
DA DNS lookup
✗ Incorrect
Active health checks send special HTTP requests to a health endpoint to verify server status.
What is passive health checking based on?
AServer uptime logs
BRegular test requests sent by NGINX
CManual server checks
DMonitoring real user traffic and errors
✗ Incorrect
Passive health checks observe real traffic and mark servers unhealthy if errors occur.
Where do you configure health checks in NGINX?
AInside the server block
BInside the location block
CInside the upstream block
DIn the http block only
✗ Incorrect
Health checks are configured inside the upstream block where backend servers are defined.
Explain how NGINX uses health checks to improve reliability.
Think about how NGINX decides which servers to send traffic to.
You got /3 concepts.
Describe how to configure a simple active health check in NGINX Plus.
Focus on the configuration syntax inside the upstream block.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of a health check in an nginx setup?
easy
A. To increase the server's CPU speed
B. To verify if a server is ready to handle requests
C. To change the server's IP address automatically
D. To backup server files regularly
Solution
Step 1: Understand health check concept
Health checks are used to confirm if a server is ready and able to serve requests.
Step 2: Identify the purpose in nginx context
In nginx, health checks help route traffic only to servers that respond correctly, ensuring reliability.
Final Answer:
To verify if a server is ready to handle requests -> Option B
Quick Check:
Health check purpose = Verify readiness [OK]
Hint: Health checks confirm server readiness to serve requests [OK]
Common Mistakes:
Thinking health checks speed up the server
Confusing health checks with backups
Assuming health checks change server IP
2. Which of the following is the correct way to define a simple health check endpoint in nginx configuration?
easy
A. location /healthcheck { return 200 "OK"; }
B. location /healthcheck { proxy_pass http://backend; }
C. location /healthcheck { error_page 404 /404.html; }
D. location /healthcheck { deny all; }
Solution
Step 1: Review nginx location syntax for health check
A simple health check returns a 200 status with a message like 'OK'.
Step 2: Identify correct return directive
location /healthcheck { return 200 "OK"; } uses return 200 "OK"; which correctly sends a success response for health checks.
Final Answer:
location /healthcheck { return 200 "OK"; } -> Option A
Quick Check:
Simple health check = return 200 [OK]
Hint: Health check returns 200 with OK message [OK]
Common Mistakes:
Using proxy_pass instead of return for simple checks
Setting error_page instead of success response
Denying access blocks health check
3. Given this nginx config snippet, what will be the HTTP status code when accessing /health?
location /health {
return 204;
}
medium
A. 204
B. 404
C. 500
D. 200
Solution
Step 1: Understand the return directive in nginx
The return 204; sends an HTTP status code 204 (No Content) response.
Step 2: Match the status code with the request
Accessing /health triggers this location and returns 204 as configured.
Final Answer:
204 -> Option A
Quick Check:
return 204 sends status 204 [OK]
Hint: return 204 sends HTTP 204 No Content status [OK]
Common Mistakes:
Assuming default 200 status without checking return
Confusing 204 with 404 or 500 errors
Ignoring the explicit return directive
4. You configured this health check in nginx:
location /healthcheck {
return 200 "OK"
}
But the health check fails with a syntax error. What is the problem?
medium
A. The return directive cannot include a message string
B. The return code 200 is invalid
C. The location block is missing a semicolon after return
D. The location path must be /health, not /healthcheck
Solution
Step 1: Check nginx configuration syntax
All nginx directives must end with a semicolon (;).
Step 2: Locate the error in the snippet
The return 200 "OK" line is missing the trailing semicolon, causing a syntax error.
Final Answer:
The location block is missing a semicolon after return -> Option C
Quick Check:
nginx directives require semicolon [OK]
Hint: Every nginx directive must end with a semicolon [OK]
Common Mistakes:
Adding message string directly after return
Missing semicolon causing syntax error
Using wrong location path for health check
5. You want to configure nginx to perform active health checks on backend servers and mark them unhealthy if they fail. Which directive and module combination should you use?
hard
A. Use proxy_pass with proxy_next_upstream and enable ngx_http_healthcheck_module
B. Use deny all in location to block unhealthy servers
C. Use return 200 in location block for backend health
D. Use check directive inside upstream block with ngx_http_upstream_check_module
Solution
Step 1: Identify active health check method in nginx
Active health checks require special modules like ngx_http_upstream_check_module and directives like check inside upstream blocks.
Step 2: Match correct directive and module
Use check directive inside upstream block with ngx_http_upstream_check_module correctly pairs check directive with ngx_http_upstream_check_module for active health checks.
Final Answer:
Use check directive inside upstream block with ngx_http_upstream_check_module -> Option D
Quick Check:
Active health checks = check + upstream_check_module [OK]
Hint: Active health checks need check directive and module [OK]
Common Mistakes:
Confusing passive proxy_next_upstream with active health checks
Using return 200 for backend health checks
Blocking servers instead of checking health
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.