Skip to content

HAProxy

HAProxy load balancer management: frontends, backends, ACLs, stats, status.

All endpoints below are mounted under /api. Authentication: Authorization: Bearer <token> unless noted as public.

Endpoint count: 28

Endpoints

Method Path Handler Guards
GET /api/haproxy/backends getHAProxyBackends RequirePermission(db, "administrative_operations")
POST /api/haproxy/backends addHAProxyBackend RequirePermission(db, "administrative_operations")
DELETE /api/haproxy/backends/:name deleteHAProxyBackend RequirePermission(db, "administrative_operations")
POST /api/haproxy/backends/:name/servers addHAProxyServer RequirePermission(db, "administrative_operations")
DELETE /api/haproxy/backends/:name/servers/:server deleteHAProxyServer RequirePermission(db, "administrative_operations")
PUT /api/haproxy/backends/:name/servers/:server updateHAProxyServer RequirePermission(db, "administrative_operations")
POST /api/haproxy/backends/duplicate duplicateHAProxyBackend RequirePermission(db, "administrative_operations")
GET /api/haproxy/backups listHAProxyBackups RequirePermission(db, "administrative_operations")
POST /api/haproxy/backups createHAProxyBackup RequirePermission(db, "administrative_operations")
DELETE /api/haproxy/backups/:name deleteHAProxyBackupFile RequirePermission(db, "administrative_operations")
POST /api/haproxy/backups/:name/restore restoreHAProxyBackup RequirePermission(db, "administrative_operations")
POST /api/haproxy/backups/auto setHAProxyAutoBackup RequirePermission(db, "administrative_operations")
GET /api/haproxy/certificates listHAProxyCertificates RequirePermission(db, "administrative_operations")
POST /api/haproxy/certificates requestHAProxyCertificate RequirePermission(db, "administrative_operations")
DELETE /api/haproxy/certificates/:domain deleteHAProxyCertificate RequirePermission(db, "administrative_operations")
GET /api/haproxy/config getHAProxyConfig RequirePermission(db, "administrative_operations")
POST /api/haproxy/config saveHAProxyConfig RequirePermission(db, "administrative_operations")
GET /api/haproxy/frontends getHAProxyFrontends RequirePermission(db, "administrative_operations")
POST /api/haproxy/frontends addHAProxyFrontend RequirePermission(db, "administrative_operations")
DELETE /api/haproxy/frontends/:name deleteHAProxyFrontend RequirePermission(db, "administrative_operations")
PUT /api/haproxy/frontends/:name updateHAProxyFrontend RequirePermission(db, "administrative_operations")
POST /api/haproxy/install installHAProxy RequirePermission(db, "administrative_operations")
POST /api/haproxy/reload haproxyAction RequirePermission(db, "administrative_operations")
POST /api/haproxy/start haproxyAction RequirePermission(db, "administrative_operations")
GET /api/haproxy/stats getHAProxyStats RequirePermission(db, "administrative_operations")
GET /api/haproxy/status getHAProxyStatus RequirePermission(db, "administrative_operations")
POST /api/haproxy/stop haproxyAction RequirePermission(db, "administrative_operations")
POST /api/haproxy/uninstall uninstallHAProxy RequirePermission(db, "administrative_operations")

Source

Handlers for this section live in api/routes/handlers_*.go in the StarkOne source. Each handler binds its request body with gin.ShouldBindJSON(&req) and responds with the standard envelope:

{ "data": { ... } }

On error:

{ "error": { "code": "string", "message": "string" } }

Note: HAProxy handlers return error bodies as { "error": { "message": "string" } } (no code field). The code field shown in the generic envelope above is not emitted by these endpoints.

Reference

GET /api/haproxy/backends

Parses /etc/haproxy/haproxy.cfg and returns all backend sections with their servers, then overlays live UP/DOWN status pulled from the HAProxy stats CSV.

Guards: RequirePermission(db, "administrative_operations")

Response - 200 OK

{ "data": [
  { "name": "local_webserver", "mode": "http", "balance": "roundrobin",
    "servers": [
      { "name": "local", "address": "127.0.0.1", "port": 10080, "weight": 1, "status": "UP", "backup": false, "ssl": false }
    ]
  }
] }

If the config file cannot be read, returns { "data": [] }. Live status comes from http://localhost:8404/stats;csv; if that fetch fails, server status stays at the parsed default "UP".

Example

curl https://panel.example.com:2087/api/haproxy/backends \
  -H "Authorization: Bearer $TOKEN"

POST /api/haproxy/backends

Appends a new backend section to the HAProxy config and reloads the service.

Guards: RequirePermission(db, "administrative_operations")

Request body

{ "name": "string (required)", "mode": "string (optional)", "balance": "string (optional)" }
Field Type Required Description
name string yes Backend name.
mode string no HAProxy mode; defaults to http when empty.
balance string no Load-balancing algorithm; defaults to roundrobin when empty.

Response - 201 Created

{ "data": { "success": true } }

Errors

Status Code Meaning
400 - Request body failed JSON binding (e.g. missing required name).
500 - Writing /etc/haproxy/haproxy.cfg failed.

Side effects

  • Appends a backend block to /etc/haproxy/haproxy.cfg.
  • Runs systemctl reload haproxy.

Example

curl -X POST https://panel.example.com:2087/api/haproxy/backends \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "app_pool", "mode": "http", "balance": "leastconn"}'

DELETE /api/haproxy/backends/:name

Removes the named backend section from the HAProxy config and reloads the service.

Guards: RequirePermission(db, "administrative_operations")

Path parameters

Name Type Description
name string Name of the backend to remove.

Response - 200 OK

{ "data": { "success": true } }

Errors

Status Code Meaning
500 - Reading or writing /etc/haproxy/haproxy.cfg failed.

Side effects

  • Deletes the matching backend block from /etc/haproxy/haproxy.cfg.
  • Runs systemctl reload haproxy.

Example

curl -X DELETE https://panel.example.com:2087/api/haproxy/backends/app_pool \
  -H "Authorization: Bearer $TOKEN"

POST /api/haproxy/backends/:name/servers

Adds a server line to the named backend and reloads HAProxy.

Guards: RequirePermission(db, "administrative_operations")

Path parameters

Name Type Description
name string Name of the backend to add the server to.

Request body

{ "name": "string (required)", "address": "string (required)", "port": "int (optional)", "weight": "int (optional)", "ssl": "bool (optional)", "backup": "bool (optional)" }
Field Type Required Description
name string yes Server name.
address string yes Server host/IP.
port int no Server port; defaults to 80 when 0. Setting it to 443 forces ssl on.
weight int no Server weight (written verbatim into weight N).
ssl bool no Append ssl verify none to the server line.
backup bool no Mark the server as a backup server.

Response - 201 Created

{ "data": { "success": true } }

Errors

Status Code Meaning
400 - Request body failed JSON binding (e.g. missing name or address).
500 - Writing /etc/haproxy/haproxy.cfg failed.

Side effects

  • Inserts a server line into the matching backend in /etc/haproxy/haproxy.cfg.
  • Runs systemctl reload haproxy.

Example

curl -X POST https://panel.example.com:2087/api/haproxy/backends/app_pool/servers \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "web1", "address": "203.0.113.10", "port": 8080, "weight": 2}'

DELETE /api/haproxy/backends/:name/servers/:server

Removes the matching server line from the named backend and reloads HAProxy.

Guards: RequirePermission(db, "administrative_operations")

Path parameters

Name Type Description
name string Backend name containing the server.
server string Name of the server to delete.

Response - 200 OK

{ "data": { "success": true } }

Errors

Status Code Meaning
500 - Writing /etc/haproxy/haproxy.cfg failed.

Side effects

  • Removes the server <name> line from the matching backend in /etc/haproxy/haproxy.cfg.
  • Runs systemctl reload haproxy.

Example

curl -X DELETE https://panel.example.com:2087/api/haproxy/backends/app_pool/servers/web1 \
  -H "Authorization: Bearer $TOKEN"

PUT /api/haproxy/backends/:name/servers/:server

Replaces the matching server line in the named backend with new values, reloads HAProxy, and waits ~300ms for stats to settle.

Guards: RequirePermission(db, "administrative_operations")

Path parameters

Name Type Description
name string Backend name containing the server.
server string Existing server name to replace.

Request body

{ "name": "string (required)", "address": "string (required)", "port": "int (optional)", "weight": "int (optional)", "ssl": "bool (optional)", "backup": "bool (optional)" }
Field Type Required Description
name string yes New server name.
address string yes New server host/IP.
port int no Server port; defaults to 80 when 0. Setting it to 443 forces ssl on.
weight int no Server weight.
ssl bool no Append ssl verify none to the server line.
backup bool no Mark the server as a backup server.

Response - 200 OK

{ "data": { "success": true } }

Errors

Status Code Meaning
400 - Request body failed JSON binding (e.g. missing name or address).
500 - Writing /etc/haproxy/haproxy.cfg failed.

Side effects

  • Rewrites the matching server line in /etc/haproxy/haproxy.cfg.
  • Runs systemctl reload haproxy and sleeps 300ms.

Example

curl -X PUT https://panel.example.com:2087/api/haproxy/backends/app_pool/servers/web1 \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "web1", "address": "203.0.113.11", "port": 8080, "weight": 3}'

POST /api/haproxy/backends/duplicate

Copies an existing backend's mode, balance, and server hosts into a new backend, rewriting all server ports to the supplied port, then reloads HAProxy.

Guards: RequirePermission(db, "administrative_operations")

Request body

{ "source": "string (required)", "name": "string (required)", "port": "int (optional)" }
Field Type Required Description
source string yes Name of the backend to copy from.
name string yes Name of the new backend.
port int no Port applied to every duplicated server; defaults to 80 when 0. Duplicated servers are renamed <name>_<n>.

Response - 201 Created

{ "data": { "success": true } }

Errors

Status Code Meaning
400 - Request body failed JSON binding (e.g. missing source or name).
404 - Source backend not found (no servers and no mode parsed).
500 - Reading or writing /etc/haproxy/haproxy.cfg failed.

Side effects

  • Appends a new backend block to /etc/haproxy/haproxy.cfg.
  • Runs systemctl reload haproxy.

Example

curl -X POST https://panel.example.com:2087/api/haproxy/backends/duplicate \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"source": "app_pool", "name": "app_pool_8443", "port": 8443}'

GET /api/haproxy/backups

Lists .cfg files in the HAProxy backup directory, sorted newest first.

Guards: RequirePermission(db, "administrative_operations")

Response - 200 OK

{ "data": [
  { "name": "haproxy_2026-06-17_02-00-00.cfg", "size": 2048, "date": "2026-06-17 02:00" }
] }

If /etc/haproxy/backups cannot be read, returns { "data": [] }.

Example

curl https://panel.example.com:2087/api/haproxy/backups \
  -H "Authorization: Bearer $TOKEN"

POST /api/haproxy/backups

Snapshots the current /etc/haproxy/haproxy.cfg into a timestamped backup file.

Guards: RequirePermission(db, "administrative_operations")

Response - 201 Created

{ "data": { "success": true, "file": "/etc/haproxy/backups/haproxy_2026-06-17_02-00-00.cfg" } }

Errors

Status Code Meaning
500 - Reading the live config or writing the backup file failed.

Side effects

  • Creates /etc/haproxy/backups if missing and writes haproxy_<timestamp>.cfg.

Example

curl -X POST https://panel.example.com:2087/api/haproxy/backups \
  -H "Authorization: Bearer $TOKEN"

DELETE /api/haproxy/backups/:name

Deletes a named backup file from the HAProxy backup directory.

Guards: RequirePermission(db, "administrative_operations")

Path parameters

Name Type Description
name string Backup file name (joined onto /etc/haproxy/backups).

Response - 200 OK

{ "data": { "success": true } }

Errors

Status Code Meaning
500 - Removing the backup file failed (e.g. file not found).

Side effects

  • Removes /etc/haproxy/backups/<name>.

Example

curl -X DELETE https://panel.example.com:2087/api/haproxy/backups/haproxy_2026-06-17_02-00-00.cfg \
  -H "Authorization: Bearer $TOKEN"

POST /api/haproxy/backups/:name/restore

Validates a named backup config, snapshots the current config as a pre_restore_* backup, restores the backup as the live config, then reloads HAProxy.

Guards: RequirePermission(db, "administrative_operations")

Path parameters

Name Type Description
name string Backup file name to restore (joined onto /etc/haproxy/backups).

Response - 200 OK

{ "data": { "success": true } }

Errors

Status Code Meaning
404 - Backup file not found.
400 - Backup failed haproxy -c validation.
500 - Writing the live config failed.

Side effects

  • Writes a pre_restore_<timestamp>.cfg snapshot of the current config into /etc/haproxy/backups.
  • Overwrites /etc/haproxy/haproxy.cfg with the backup contents.
  • Validates via haproxy -c -f /tmp/haproxy_restore_test.cfg (temp file removed after).
  • Runs systemctl reload haproxy.

Example

curl -X POST https://panel.example.com:2087/api/haproxy/backups/haproxy_2026-06-17_02-00-00.cfg/restore \
  -H "Authorization: Bearer $TOKEN"

POST /api/haproxy/backups/auto

Enables or disables a daily cron job that backs up the HAProxy config.

Guards: RequirePermission(db, "administrative_operations")

Request body

{ "enabled": "bool (optional)" }
Field Type Required Description
enabled bool no When true, installs the cron file; when false, removes it.

Response - 200 OK

{ "data": { "success": true } }

Errors

Status Code Meaning
400 - Request body failed JSON binding.

Side effects

  • When enabled: writes /etc/cron.d/haproxy-backup running starkone-cli haproxy_backup daily at 02:00.
  • When disabled: removes /etc/cron.d/haproxy-backup.

Example

curl -X POST https://panel.example.com:2087/api/haproxy/backups/auto \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"enabled": true}'

GET /api/haproxy/certificates

Lists .pem certificate files in /etc/haproxy/certs (excluding default.pem), reading each cert's expiry via openssl.

Guards: RequirePermission(db, "administrative_operations")

Response - 200 OK

{ "data": [
  { "domain": "example.com", "file": "example.com.pem", "size": 5120, "modified": "2026-06-17 02:00", "expiry": "Sep 15 12:00:00 2026 GMT" }
] }

If /etc/haproxy/certs cannot be read, returns { "data": [] }. expiry is empty if openssl fails.

Side effects

  • Reads each cert via openssl x509 -enddate -noout -in <path> (read-only).

Example

curl https://panel.example.com:2087/api/haproxy/certificates \
  -H "Authorization: Bearer $TOKEN"

POST /api/haproxy/certificates

Requests a Let's Encrypt certificate (for the domain and its www. variant) via certbot webroot, writes a combined PEM for HAProxy, and reloads HAProxy. Installs certbot first if missing.

Guards: RequirePermission(db, "administrative_operations")

Request body

{ "domain": "string (required)", "email": "string (optional)" }
Field Type Required Description
domain string yes Domain to issue the certificate for; www.<domain> is added automatically.
email string no ACME registration email; if empty, registers with --register-unsafely-without-email.

Response - 201 Created

{ "data": { "success": true, "domain": "example.com" } }

Errors

Status Code Meaning
400 - Request body failed JSON binding (e.g. missing domain).
500 - Certbot failed, or reading fullchain/privkey or writing the combined cert failed.

Side effects

  • May install certbot via the system package manager.
  • Runs certbot certonly --webroot -w /var/www/acme ....
  • Writes /etc/haproxy/certs/<domain>.pem (combined fullchain + privkey).
  • Runs systemctl reload haproxy.

Example

curl -X POST https://panel.example.com:2087/api/haproxy/certificates \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"domain": "example.com", "email": "[email protected]"}'

DELETE /api/haproxy/certificates/:domain

Deletes the HAProxy combined cert for a domain, best-effort revokes/deletes it from certbot, and reloads HAProxy.

Guards: RequirePermission(db, "administrative_operations")

Path parameters

Name Type Description
domain string Domain whose cert (/etc/haproxy/certs/<domain>.pem) is removed.

Response - 200 OK

{ "data": { "success": true } }

Errors

Status Code Meaning
500 - Removing /etc/haproxy/certs/<domain>.pem failed.

Side effects

  • Removes /etc/haproxy/certs/<domain>.pem.
  • Best-effort certbot revoke and certbot delete for the domain (failures ignored).
  • Runs systemctl reload haproxy.

Example

curl -X DELETE https://panel.example.com:2087/api/haproxy/certificates/example.com \
  -H "Authorization: Bearer $TOKEN"

GET /api/haproxy/config

Returns the raw contents of /etc/haproxy/haproxy.cfg.

Guards: RequirePermission(db, "administrative_operations")

Response - 200 OK

{ "data": { "content": "global\n    log /dev/log local0\n..." } }

If the config file cannot be read, returns { "data": { "content": "" } }.

Example

curl https://panel.example.com:2087/api/haproxy/config \
  -H "Authorization: Bearer $TOKEN"

POST /api/haproxy/config

Validates submitted config text with haproxy -c, writes it to /etc/haproxy/haproxy.cfg, and reloads HAProxy.

Guards: RequirePermission(db, "administrative_operations")

Request body

{ "content": "string (required)" }
Field Type Required Description
content string yes Full HAProxy config to write.

Response - 200 OK

{ "data": { "success": true } }

Errors

Status Code Meaning
400 - Request body failed JSON binding, or config failed haproxy -c validation.
500 - Writing /etc/haproxy/haproxy.cfg failed.

Side effects

  • Validates via haproxy -c -f /tmp/haproxy_test.cfg (temp file removed after).
  • Overwrites /etc/haproxy/haproxy.cfg.
  • Runs systemctl reload haproxy.

Example

curl -X POST https://panel.example.com:2087/api/haproxy/config \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"content": "global\n    daemon\ndefaults\n    mode http\n"}'

GET /api/haproxy/frontends

Parses /etc/haproxy/haproxy.cfg and returns all frontend sections with bind, mode, SSL flag, and default backend.

Guards: RequirePermission(db, "administrative_operations")

Response - 200 OK

{ "data": [
  { "name": "http_front", "bind": "*:80", "mode": "http", "ssl": false, "default_backend": "local_webserver", "status": "OPEN" }
] }

If the config file cannot be read, returns { "data": [] }.

Example

curl https://panel.example.com:2087/api/haproxy/frontends \
  -H "Authorization: Bearer $TOKEN"

POST /api/haproxy/frontends

Appends a new frontend section to the HAProxy config and reloads the service.

Guards: RequirePermission(db, "administrative_operations")

Request body

{ "name": "string (required)", "bind": "string (required)", "mode": "string (optional)", "default_backend": "string (optional)", "ssl": "bool (optional)", "ssl_cert": "string (optional)" }
Field Type Required Description
name string yes Frontend name.
bind string yes Bind address, e.g. *:443.
mode string no HAProxy mode; defaults to http when empty.
default_backend string no Default backend name; omitted from config if empty.
ssl bool no Enable SSL on the bind line (only applied when ssl_cert is also set).
ssl_cert string no Path to the combined cert; when ssl is true, written as ssl crt <ssl_cert>.

Response - 201 Created

{ "data": { "success": true } }

Errors

Status Code Meaning
400 - Request body failed JSON binding (e.g. missing name or bind).
409 - A frontend with that name already exists.
500 - Writing /etc/haproxy/haproxy.cfg failed.

Side effects

  • Appends a frontend block to /etc/haproxy/haproxy.cfg.
  • When ssl and ssl_cert are set, may generate a combined cert via ensureHAProxyCombinedCert.
  • Runs systemctl reload haproxy.

Example

curl -X POST https://panel.example.com:2087/api/haproxy/frontends \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "https_app", "bind": "*:443", "mode": "http", "default_backend": "app_pool", "ssl": true, "ssl_cert": "/etc/haproxy/certs/example.com.pem"}'

DELETE /api/haproxy/frontends/:name

Removes the named frontend section from the HAProxy config and reloads the service.

Guards: RequirePermission(db, "administrative_operations")

Path parameters

Name Type Description
name string Name of the frontend to remove.

Response - 200 OK

{ "data": { "success": true } }

Errors

Status Code Meaning
500 - Reading or writing /etc/haproxy/haproxy.cfg failed.

Side effects

  • Deletes the matching frontend block from /etc/haproxy/haproxy.cfg.
  • Runs systemctl reload haproxy.

Example

curl -X DELETE https://panel.example.com:2087/api/haproxy/frontends/https_app \
  -H "Authorization: Bearer $TOKEN"

PUT /api/haproxy/frontends/:name

Rewrites the named frontend block with new bind/mode/SSL/default-backend values while preserving its existing ACL and use_backend rules, then reloads HAProxy.

Guards: RequirePermission(db, "administrative_operations")

Path parameters

Name Type Description
name string Name of the frontend to update.

Request body

{ "bind": "string (optional)", "mode": "string (optional)", "default_backend": "string (optional)", "ssl": "bool (optional)", "ssl_cert": "string (optional)" }
Field Type Required Description
bind string no New bind address.
mode string no HAProxy mode; defaults to http when empty.
default_backend string no Default backend name; omitted if empty.
ssl bool no Enable SSL on the bind line. With ssl_cert set, uses that cert; without it, uses ssl crt /etc/haproxy/certs/ alpn h2,http/1.1.
ssl_cert string no Path to a combined cert used when ssl is true.

Response - 200 OK

{ "data": { "success": true } }

Errors

Status Code Meaning
400 - Request body failed JSON binding.
404 - Frontend with that name not found.
500 - Writing /etc/haproxy/haproxy.cfg failed.

Side effects

  • Replaces the matching frontend block in /etc/haproxy/haproxy.cfg (preserving acl/use_backend lines).
  • When ssl and ssl_cert are set, may generate a combined cert.
  • Runs systemctl reload haproxy.

Example

curl -X PUT https://panel.example.com:2087/api/haproxy/frontends/https_app \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"bind": "*:443", "mode": "http", "default_backend": "app_pool", "ssl": true}'

POST /api/haproxy/install

Marks the HAProxy plugin enabled, installs the HAProxy package, rewrites vhosts to backend ports, writes a default config plus ACME/cert deploy hooks and a placeholder cert, then enables and starts the service.

Guards: RequirePermission(db, "administrative_operations")

Response - 200 OK

{ "data": { "success": true } }

Errors

Status Code Meaning
500 - No supported package manager found, or package install failed.

Side effects

  • Upserts the haproxy row (enabled) in /etc/starkone/starkone.db.
  • Installs HAProxy via apt-get/dnf/yum.
  • Runs the CLI rewrite_all to move vhosts to backend port 10080.
  • Creates /var/www/acme/.well-known/acme-challenge, /etc/haproxy/certs, and /etc/letsencrypt/renewal-hooks/deploy.
  • Writes the certbot deploy hook haproxy-sync.sh, the default /etc/haproxy/haproxy.cfg, and a self-signed placeholder cert.
  • Runs systemctl enable haproxy and systemctl start haproxy.

Example

curl -X POST https://panel.example.com:2087/api/haproxy/install \
  -H "Authorization: Bearer $TOKEN"

POST /api/haproxy/reload

Validates the config with haproxy -c and then reloads the HAProxy service. (Handled by the shared haproxyAction with action reload.)

Guards: RequirePermission(db, "administrative_operations")

Response - 200 OK

{ "data": { "success": true } }

Errors

Status Code Meaning
400 - Config failed haproxy -c validation.
500 - systemctl reload haproxy failed.

Side effects

  • Runs haproxy -c -f /etc/haproxy/haproxy.cfg then systemctl reload haproxy.

Example

curl -X POST https://panel.example.com:2087/api/haproxy/reload \
  -H "Authorization: Bearer $TOKEN"

POST /api/haproxy/start

Starts the HAProxy service. (Handled by the shared haproxyAction with action start.)

Guards: RequirePermission(db, "administrative_operations")

Response - 200 OK

{ "data": { "success": true } }

Errors

Status Code Meaning
500 - systemctl start haproxy failed.

Side effects

  • Runs systemctl start haproxy.

Example

curl -X POST https://panel.example.com:2087/api/haproxy/start \
  -H "Authorization: Bearer $TOKEN"

GET /api/haproxy/stats

Returns aggregate FRONTEND traffic stats parsed from the HAProxy stats CSV.

Guards: RequirePermission(db, "administrative_operations")

Response - 200 OK

{ "data": { "current_sessions": 0, "total_requests": 0, "bytes_in": 0, "bytes_out": 0 } }

Values are summed across FRONTEND rows from http://localhost:8404/stats;csv. If that fetch fails, zeroed defaults are returned.

Example

curl https://panel.example.com:2087/api/haproxy/stats \
  -H "Authorization: Bearer $TOKEN"

GET /api/haproxy/status

Reports whether HAProxy is installed and running, plus version and memory usage.

Guards: RequirePermission(db, "administrative_operations")

Response - 200 OK

{ "data": { "installed": true, "running": true, "version": "2.6.12-1", "memory_mb": 24 } }

If /usr/sbin/haproxy is absent, returns { "data": { "installed": false, "running": false } } (no version/memory_mb).

Side effects

  • Reads service state via systemctl is-active haproxy, haproxy -v, and ps (read-only).

Example

curl https://panel.example.com:2087/api/haproxy/status \
  -H "Authorization: Bearer $TOKEN"

POST /api/haproxy/stop

Stops the HAProxy service. (Handled by the shared haproxyAction with action stop.)

Guards: RequirePermission(db, "administrative_operations")

Response - 200 OK

{ "data": { "success": true } }

Errors

Status Code Meaning
500 - systemctl stop haproxy failed.

Side effects

  • Runs systemctl stop haproxy.

Example

curl -X POST https://panel.example.com:2087/api/haproxy/stop \
  -H "Authorization: Bearer $TOKEN"

POST /api/haproxy/uninstall

Stops and disables HAProxy, restores the web server's original ports, and removes the HAProxy package.

Guards: RequirePermission(db, "administrative_operations")

Response - 200 OK

{ "data": { "success": true } }

Side effects

  • Runs systemctl stop haproxy and systemctl disable haproxy.
  • Restores Apache/Nginx ports via restoreWebServerPorts.
  • Removes the HAProxy package via apt-get/dnf/yum.

Example

curl -X POST https://panel.example.com:2087/api/haproxy/uninstall \
  -H "Authorization: Bearer $TOKEN"