Plus health and dynamic management
Add active health checks to a shared upstream
Passive detection learns from ordinary traffic; active checks send separate probes on a schedule. In the commercial HTTP module, a shared upstream zone is required. The example uses a readiness endpoint, two consecutive failures and two successful probes for recovery. mandatory keeps a new peer in checking state until it passes the initial check. Use a cheap readiness endpoint that reflects ability to serve; do not make a probe depend on unrelated systems. The following is a partial Plus configuration, not an OSS example.
upstream catalog { zone catalog 64k; server 127.0.0.1:19081; server 127.0.0.1:19082;}server { listen 127.0.0.1:19080; location / { proxy_pass http://catalog; health_check uri=/ready interval=5s fails=2 passes=2 mandatory; }}Interpret monitoring data before changing traffic
The Plus API reports upstream and other runtime state, and the dashboard presents operational metrics. Use a separately restricted read-only listener for monitoring. The snapshot below is a simplified teaching projection, not the actual API response schema. A peer marked unhealthy must not be interpreted as proof of a host outage: inspect the readiness response and dependency logs. A counter reset or process replacement can change metric baselines. The mock fixture includes one failed peer and one eligible peer.
{ "group": "catalog", "peers": [ { "id": 11, "state": "up" }, { "id": 12, "state": "unhealthy" } ], "synthetic": true}Separate observation from management
The commercial api directive supports read-only mode and optional writes. Keep it separate from application traffic. The partial config below illustrates an isolated read-only monitoring server. Loopback is a minimal local fixture boundary, not sufficient protection against other local processes. Production needs a private management network, authenticated operator identity, authorization, transport protection and audit. Never expose a write-enabled API publicly. Use the API version advertised by the selected release and verify the actual endpoint schema before automation.
server { listen 127.0.0.1:19090; location /api/ { allow 127.0.0.1; deny all; api write=off; }}Reconcile runtime changes and key-value state
Runtime edits can change peer weights or membership without a full reload. Use approved before/after snapshots, staged changes and health verification; record the desired state in a controlled source of truth. The commercial state directive stores upstream peer settings in a file, cannot be combined with server directives in that group, and has documented reload/upgrade caveats. keyval_zone defines storage and keyval maps a lookup into a variable; it is not a general-purpose distributed database. The example is partial, http-context only; no API writes are enabled in the lab. For missing values use an explicit safe policy.
keyval_zone zone=labels:64k;keyval $arg_region $region_label zone=labels;# Illustrative lookup of non-sensitive display labels only.Practice and evidence
Read snapshot.json and run verify_offline.py. Explain which peer is eligible, why a read-only API is safer, and how to reconcile a future approved peer change with Git. Peer 11 is eligible in this mock. Peer 12 is unhealthy. Runtime changes require authorization, audit, state reconciliation and rollback. See the staged manual practice and lab in this package. References: nginx-http-upstream-hc-health-check, nginx-http-api-api, nginx-http-keyval-keyval, nginx-http-keyval-keyval-zone. Next: nginx-licensing-and-support-operations.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Plus health and dynamic management
Assess edition and enterprise operations reasoning.
Why configure a shared upstream zone for these active probes?
What does mandatory do for a new peer in the example?
Which peer is eligible in the synthetic snapshot?
What is the correct default for a monitoring-only API listener?
How should runtime changes be handled?