You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+46-6Lines changed: 46 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,13 +39,48 @@ services:
39
39
40
40
```bash
41
41
curl http://localhost/health
42
-
# Returns: upstream response or "UPSTREAM_UNAVAILABLE" (503) if upstream is down
43
-
# Includes X-Upstream-Status header showing actual upstream response code
42
+
# Returns: OK
44
43
```
45
44
46
-
The health endpoint now proxies to the upstream server to verify connectivity. If the upstream is unavailable, it returns 503 with "UPSTREAM_UNAVAILABLE".
45
+
`/health` is a lightweight liveness check for NGINX itself. Use `/status` for upstream reachability, cache totals, and connection counters.
47
46
48
-
**Health Monitoring**: A background process logs warnings every 5 minutes if the upstream server becomes unreachable, but the container continues running to serve cached content.
47
+
### Status Endpoint
48
+
49
+
```bash
50
+
curl http://localhost/status
51
+
```
52
+
53
+
Example response:
54
+
55
+
```json
56
+
{
57
+
"updated_at": "2026-03-24T12:00:00Z",
58
+
"health": {
59
+
"nginx": true,
60
+
"upstream": true
61
+
},
62
+
"upstream": {
63
+
"host": "owl.virtualflybrain.org",
64
+
"port": 80
65
+
},
66
+
"cache": {
67
+
"source": "access_log",
68
+
"total": 120,
69
+
"hit": 113,
70
+
"miss": 7
71
+
},
72
+
"connections": {
73
+
"active": 3,
74
+
"reading": 0,
75
+
"writing": 1,
76
+
"waiting": 2
77
+
}
78
+
}
79
+
```
80
+
81
+
`/status` is refreshed by a background monitor that reads the access log for cache totals and samples NGINX `stub_status` for connection counters.
82
+
83
+
**Health Monitoring**: A background process logs warnings when the upstream server becomes unreachable, but the container continues running to serve cached content.
49
84
50
85
## Configuration
51
86
@@ -55,12 +90,14 @@ The health endpoint now proxies to the upstream server to verify connectivity. I
55
90
-`CACHE_MAX_SIZE`: Maximum cache size on disk (default: `20g`, accepts NGINX size units like `1t` for 1TB)
56
91
-`CACHE_STALE_TIME`: How long a cached response is considered fresh (default: `6M`). After this time the entry is served stale while being refreshed in the background. Accepts NGINX time units: `s`, `m`, `h`, `d`, `w`, `M` (30 days), `y` (365 days).
57
92
-`DNS_RESOLVER`: DNS resolver servers (default: `8.8.8.8`, space-separated list). Check `cat /etc/resolv.conf` in your container to find the correct value for your environment.
93
+
-`STATUS_POLL_INTERVAL`: Seconds between `/status` refreshes (default: `5`)
94
+
-`HEALTH_LOG_INTERVAL`: Seconds between periodic upstream health log lines when state is unchanged (default: `300`)
58
95
59
96
### Cache Headers
60
97
61
98
The proxy adds helpful headers to responses:
62
99
63
-
-`X-Cache-Status`: `HIT`, `MISS`, `EXPIRED`, or `STALE`
100
+
-`X-Cache-Status`: `HIT`, `MISS`, `EXPIRED`, `STALE`, `UPDATING`, or `REVALIDATED`
64
101
-`X-Cache-Key`: The cache key used for the request
65
102
66
103
## Performance
@@ -80,7 +117,8 @@ The proxy adds helpful headers to responses:
80
117
-**Cache storage**: `/var/cache/nginx/owlery` with 1:2 directory levels
81
118
-**Cache zone**: 100MB in-memory metadata zone
82
119
-**Max cache size**: 20GB on disk (configurable via `CACHE_MAX_SIZE` environment variable)
83
-
-**Health monitoring**: Background process checks upstream connectivity every 5 minutes and logs warnings
120
+
-**Status monitoring**: Background process updates `/var/run/nginx/status.json` from the access log and NGINX `stub_status`
121
+
-**Health monitoring**: Background process checks upstream connectivity and logs warnings without taking the cache offline
84
122
85
123
### Caching Behavior
86
124
@@ -95,6 +133,7 @@ The proxy adds helpful headers to responses:
95
133
### Networking
96
134
97
135
-**Listen ports**: 80 and 8080 (both ports handle requests identically)
136
+
-**Status endpoints**: `/health` for liveness, `/status` for JSON metrics, and internal-only `/__nginx_status` for raw NGINX counters
98
137
-**DNS resolver**: Configurable via `DNS_RESOLVER` (default: Google Public DNS `8.8.8.8` with 30s TTL for fast upstream IP updates). Check `cat /etc/resolv.conf` in your container for the correct value.
99
138
-**Host-agnostic**: Ignores Host header for routing
100
139
-**Connection pooling**: 16 keep-alive connections to backend
@@ -147,3 +186,4 @@ Set these in your GitHub repository secrets:
147
186
-**Subsequent Requests**: Cache HIT → Return cached result (<10ms) with X-Cache-Status: HIT
148
187
-**Expired Cache**: Return stale content immediately with X-Cache-Status: UPDATING + background refresh
149
188
-**Backend Errors**: Forward errors to client without caching, allowing retries to succeed
189
+
-**Status Reporting**: `/status` shows current hit/miss/total counts from the access log plus sampled connection counters
0 commit comments