Tutorials

Manage global settings

In your load balancer configuration, a global section defines settings that affect how the load balancer runs.

You can manage global settings programmatically by calling the API endpoint /services/haproxy/configuration/global.

Getting and setting the version parameter Jump to heading

When making a POST, PUT, or DELETE API call, you must add the version URL parameter. For example:

nix
http://localhost:5555/v3/services/haproxy/configuration/backends/myservers?version=1
nix
http://localhost:5555/v3/services/haproxy/configuration/backends/myservers?version=1

The version parameter must match the load balancer’s current configuration version. This is because the Data Plane API uses optimistic concurrency control, or optimistic locking, to manage its transactions. This ensures that if multiple entities modify a resource that the changes are applied correctly. The APIv3 examples in this section make a GET request to /v3/services/haproxy/configuration/version immediately before making a call to update a resource to retrieve the version and populate the CFGVER environment variable for the URL version parameter as is shown in the following command:

nix
CFGVER=$(curl --silent --user admin:adminpwd http://localhost:5555/v3/services/haproxy/configuration/version)
nix
CFGVER=$(curl --silent --user admin:adminpwd http://localhost:5555/v3/services/haproxy/configuration/version)

You will then use the value of the environment variable to populate the version parameter in the endpoint URL. An example URL may look like this. Note the environment variable reference, $CFGVER:

nix
http://localhost:5555/v3/services/haproxy/configuration/backends/myservers?version=$CFGVER
nix
http://localhost:5555/v3/services/haproxy/configuration/backends/myservers?version=$CFGVER

Response codes and reloads Jump to heading

Inside a transaction, a change is written to the transaction instead of the configuration file, so nothing reaches the file until you commit, and the commit answers 202 Accepted.

When a change needs a reload, the API applies it in the background. By default it writes your change, schedules the reload, and answers 202 Accepted with a Reload-ID header:

output
text
HTTP 202 Accepted
Reload-ID: 2026-10-29-0
output
text
HTTP 202 Accepted
Reload-ID: 2026-10-29-0

To wait for the reload before returning, add force_reload=true to the request. The status code then reports the outcome directly, and no reload ID comes back:

Request Default With force_reload=true
POST, to create 202 Accepted 201 Created
PUT, to replace 202 Accepted 200 OK
DELETE 202 Accepted 204 No Content

The code reflects what the request did: a create answers 201 Created because it made a resource, a replace answers 200 OK because it changed an existing one, and a delete answers 204 No Content because there is nothing left to return.

Some changes, such as adding a server to a backend, are applied through the HAProxy Runtime API instead of a reload. Those answer 201 Created without waiting for a reload.

To follow a scheduled reload, you can pass the ID from the Reload-ID header to the reloads endpoint of the service:

nix
curl --request GET \
--user admin:adminpwd \
"http://localhost:5555/v3/services/haproxy/reloads/2026-10-29-0"
nix
curl --request GET \
--user admin:adminpwd \
"http://localhost:5555/v3/services/haproxy/reloads/2026-10-29-0"
output
json
{
"id": "2026-10-29-0",
"reload_timestamp": 1793301215,
"status": "succeeded"
}
output
json
{
"id": "2026-10-29-0",
"reload_timestamp": 1793301215,
"status": "succeeded"
}

The reloads endpoints are /services/haproxy/reloads, /services/keepalived/reloads, and /services/gslb/reloads, each with an /{id} variant. Inside a transaction, a change is written to the transaction instead of the configuration file, which means nothing reaches the file until you commit, and the commit returns 202 Accepted.

List global settings Jump to heading

To get the contents of a global section, make a GET request to the global endpoint:

nix
curl --request GET \
--user admin:adminpwd \
"http://localhost:5555/v3/services/haproxy/configuration/global"
nix
curl --request GET \
--user admin:adminpwd \
"http://localhost:5555/v3/services/haproxy/configuration/global"
output
json
{
"runtime_apis": [
{
"level": "admin",
"mode": "660",
"address": "/var/run/haproxy.sock"
}
],
"insecure_fork_wanted": true,
"master-worker": true
}
output
json
{
"runtime_apis": [
{
"level": "admin",
"mode": "660",
"address": "/var/run/haproxy.sock"
}
],
"insecure_fork_wanted": true,
"master-worker": true
}
nix
curl --request GET \
--user admin:adminpwd \
"http://localhost:5555/v2/services/haproxy/configuration/global"
nix
curl --request GET \
--user admin:adminpwd \
"http://localhost:5555/v2/services/haproxy/configuration/global"
output
json
{
"_version": 99,
"data": {
"runtime_apis": [
{
"level": "admin",
"mode": "660",
"address": "/var/run/haproxy.sock"
}
],
"insecure_fork_wanted": true,
"master-worker": true
}
}
output
json
{
"_version": 99,
"data": {
"runtime_apis": [
{
"level": "admin",
"mode": "660",
"address": "/var/run/haproxy.sock"
}
],
"insecure_fork_wanted": true,
"master-worker": true
}
}

Replace global settings Jump to heading

To make changes to global settings, you must replace them entirely. To replace global settings, make a PUT request to the global endpoint, passing the fields in the body of the request. Note that prior to making the PUT request, you must first capture the current version in an environment variable (CFGVER in this example) and use the value in your request. In this example, we replace the settings to include maxconn, user, group, pidfile, and runtime_apis:

nix
CFGVER=$(curl -s -u admin:adminpwd http://localhost:5555/v3/services/haproxy/configuration/version)
curl --request PUT \
--user admin:adminpwd \
--header "Content-Type: application/json" \
-d '{
"maxconn": 100000,
"chroot": "/var/empty",
"user": "haproxy",
"group": "haproxy",
"pidfile": "/var/run/haproxy/haproxy.pid",
"runtime_apis": [
{
"address": "/var/run/haproxy.sock",
"level": "admin",
"mode": "660"
},
{
"address": "ipv4@0.0.0.0:9999",
"level": "admin"
}
]
}' \
"http://localhost:5555/v3/services/haproxy/configuration/global?version=$CFGVER"
nix
CFGVER=$(curl -s -u admin:adminpwd http://localhost:5555/v3/services/haproxy/configuration/version)
curl --request PUT \
--user admin:adminpwd \
--header "Content-Type: application/json" \
-d '{
"maxconn": 100000,
"chroot": "/var/empty",
"user": "haproxy",
"group": "haproxy",
"pidfile": "/var/run/haproxy/haproxy.pid",
"runtime_apis": [
{
"address": "/var/run/haproxy.sock",
"level": "admin",
"mode": "660"
},
{
"address": "ipv4@0.0.0.0:9999",
"level": "admin"
}
]
}' \
"http://localhost:5555/v3/services/haproxy/configuration/global?version=$CFGVER"
nix
CFGVER=$(curl -s -u admin:adminpwd http://localhost:5555/v2/services/haproxy/configuration/version)
curl --request PUT \
--user admin:adminpwd \
--header "Content-Type: application/json" \
-d '{
"maxconn": 100000,
"chroot": "/var/empty",
"user": "haproxy",
"group": "haproxy",
"pidfile": "/var/run/haproxy/haproxy.pid",
"runtime_apis": [
{
"address": "/var/run/haproxy.sock",
"level": "admin",
"mode": "660"
},
{
"address": "ipv4@0.0.0.0:9999",
"level": "admin"
}
]
}' \
"http://localhost:5555/v2/services/haproxy/configuration/global?version=$CFGVER"
nix
CFGVER=$(curl -s -u admin:adminpwd http://localhost:5555/v2/services/haproxy/configuration/version)
curl --request PUT \
--user admin:adminpwd \
--header "Content-Type: application/json" \
-d '{
"maxconn": 100000,
"chroot": "/var/empty",
"user": "haproxy",
"group": "haproxy",
"pidfile": "/var/run/haproxy/haproxy.pid",
"runtime_apis": [
{
"address": "/var/run/haproxy.sock",
"level": "admin",
"mode": "660"
},
{
"address": "ipv4@0.0.0.0:9999",
"level": "admin"
}
]
}' \
"http://localhost:5555/v2/services/haproxy/configuration/global?version=$CFGVER"

Do you have any suggestions on how we can improve the content of this page? Please leave feedback!