Configuration
Monitoring
Health, readiness and metrics endpoints for load balancers, orchestrators and Prometheus exporters.
Health
GET /health on the application port returns 200 OK as soon as Nginx is up. It is served by Nginx directly, so it says nothing about PHP-FPM; use it for load balancer and orchestrator liveness probes, and the image's own HEALTHCHECK uses it too.
Metrics listener
Set NGINX_METRICS_PORT to open a second listener that is never served on the application port:
| Path | Source | Content |
|---|---|---|
/nginx_status | nginx stub_status | active connections, accepts, handled, requests, reading/writing/waiting |
/fpm-status | PHP-FPM pm.status_path | pool, process manager, active/idle/total processes, slow requests, queue; append ?json, ?xml or ?full |
/fpm-ping | PHP-FPM ping.path | pong when FPM accepts connections, which makes it the readiness probe PHP actually needs |
/health | nginx | the same OK as the application port |
docker run --rm -d -p 8080:8080 -p 127.0.0.1:9090:9090 \
-e NGINX_PORT=8080 -e NGINX_METRICS_PORT=9090 \
rollogi/php-nginx:8.4
curl -s localhost:9090/nginx_status
curl -s "localhost:9090/fpm-status?json" | jq .
curl -s localhost:9090/fpm-ping
NGINX_METRICS_ALLOW takes an address or CIDR for the allow directive (default all). The safer pattern is to not publish the port at all and let your exporters reach it over the container network.
Prometheus
The endpoints are the ones the standard exporters consume:
compose.yaml
services:
app:
image: rollogi/php-nginx:8.4
environment:
NGINX_PORT: 8080
NGINX_METRICS_PORT: 9090
nginx-exporter:
image: nginx/nginx-prometheus-exporter:1.4.2
command: ["--nginx.scrape-uri=http://app:9090/nginx_status"]
fpm-exporter:
image: hipages/php-fpm_exporter:2.2.0
environment:
PHP_FPM_SCRAPE_URI: tcp://app:9090/fpm-status
Kubernetes probes
livenessProbe:
httpGet: { path: /health, port: 8080 }
readinessProbe:
httpGet: { path: /fpm-ping, port: 9090 }
Readiness on /fpm-ping means a pod only receives traffic once PHP-FPM is accepting connections, not merely when Nginx is listening.