Tutorials

Manage default settings

In your load balancer configuration, a defaults section defines settings that apply when a frontend, backend, or listen section that follows it doesn’t set those same settings. It offers a way to store common settings in one place.

Note

The version parameter in DELETE, POST, and PUT requests must match the system’s current version. The examples in this section use a GET request to /v2/services/haproxy/configuration/version to retrieve the version and populate the CFGVER environment variable for the URL version parameter.

List defaults Jump to heading

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

nix
curl -X GET \
--user admin:adminpwd \
"http://127.0.0.1:5555/v2/services/haproxy/configuration/defaults"
nix
curl -X GET \
--user admin:adminpwd \
"http://127.0.0.1:5555/v2/services/haproxy/configuration/defaults"
output
json
{
"_version":5,
"data":{
"error_files":null,
"client_timeout":30000,
"connect_timeout":10000,
"dontlognull":"enabled",
"forwardfor":{
"enabled":"enabled",
"except":"127.0.0.0/8"
},
"httplog":true,
"mode":"http",
"redispatch":{
"enabled":"enabled"
},
"retries":3,
"server_timeout":30000
}
}
output
json
{
"_version":5,
"data":{
"error_files":null,
"client_timeout":30000,
"connect_timeout":10000,
"dontlognull":"enabled",
"forwardfor":{
"enabled":"enabled",
"except":"127.0.0.0/8"
},
"httplog":true,
"mode":"http",
"redispatch":{
"enabled":"enabled"
},
"retries":3,
"server_timeout":30000
}
}

Replace defaults Jump to heading

To make changes to a defaults section, you must replace its contents entirely. To replace a defaults section, make a PUT request to the defaults endpoint:

nix
CFGVER=$(curl -s -u admin:adminpwd http://localhost:5555/v2/services/haproxy/configuration/version)
curl -X PUT \
--user admin:adminpwd \
-H "Content-Type: application/json" \
-d '{
"error_files":null,
"client_timeout":10000,
"connect_timeout":5000,
"dontlognull":"enabled",
"forwardfor":{
"enabled":"enabled",
"except":"127.0.0.0/8"
},
"httplog":true,
"mode":"http",
"redispatch":{
"enabled":"enabled"
},
"retries":3,
"server_timeout":10000
}' \
"http://127.0.0.1:5555/v2/services/haproxy/configuration/defaults?version=$CFGVER"
nix
CFGVER=$(curl -s -u admin:adminpwd http://localhost:5555/v2/services/haproxy/configuration/version)
curl -X PUT \
--user admin:adminpwd \
-H "Content-Type: application/json" \
-d '{
"error_files":null,
"client_timeout":10000,
"connect_timeout":5000,
"dontlognull":"enabled",
"forwardfor":{
"enabled":"enabled",
"except":"127.0.0.0/8"
},
"httplog":true,
"mode":"http",
"redispatch":{
"enabled":"enabled"
},
"retries":3,
"server_timeout":10000
}' \
"http://127.0.0.1:5555/v2/services/haproxy/configuration/defaults?version=$CFGVER"

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