fix(haproxy-stats): add stats socket to template + fix safeAt index-0 bug

Two root causes for Dashboard backends not showing:
1. haproxy.cfg.tpl had no stats socket directive → /run/haproxy/admin.sock
   never created → handler got "connection refused" → empty array returned.
   Fixed: added stats socket /run/haproxy/admin.sock mode 0660 level admin.
2. safeAt() used i<=0 instead of i<0 → pxname (column 0) always returned ""
   → all backend names were empty in the API response.
After upgrade: HAProxy reload (triggered by any domain/backend save, or
edgeguard-ctl render-config) will create the socket. v1.1.113.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Debian
2026-05-27 07:36:31 +02:00
parent da554e9e82
commit 67c5180168
6 changed files with 8 additions and 5 deletions

View File

@@ -135,7 +135,7 @@ func (h *HAProxyStatsHandler) Stats(c *gin.Context) {
}
func safeAt(fields []string, i int) string {
if i <= 0 || i >= len(fields) {
if i < 0 || i >= len(fields) {
return ""
}
return fields[i]

View File

@@ -15,6 +15,9 @@ global
# Ohne dieses Flag verweigert HAProxy `bind quic4@…` mit "this SSL
# library does not support the QUIC protocol".
limited-quic
# Runtime-API-Socket für edgeguard-api (show stat, show info, …).
# mode 0660 + group haproxy → edgeguard-user (in haproxy-group) kann lesen.
stats socket /run/haproxy/admin.sock mode 0660 level admin expose-fd listeners
defaults
log global