Administration
Manage HAProxy Enterprise configuration files
This page applies to:
- HAProxy Enterprise - all versions
By default, the HAProxy Enterprise service loads only the configuration file, /etc/hapee-<VERSION>/hapee-lb.cfg.
Validate your configuration Jump to heading
You can validate a configuration file using the hapee-lb program with the -c flag.
Depending on your version, the command’s output indicates that the file is valid in these ways:
- In version 2.8 and earlier, the command indicates a valid configuration by printing
Configuration file is validin addition to setting the zero return status. - In version 2.9 and later, the command sets the zero return status for a valid configuration but does not display a message. To display the message, include the
-Voption on the command line.
Example:
nixsudo /opt/hapee-3.2/sbin/hapee-lb -c -f /etc/hapee-3.2/hapee-lb.cfg -V
nixsudo /opt/hapee-3.2/sbin/hapee-lb -c -f /etc/hapee-3.2/hapee-lb.cfg -V
Alerts and warnings that appear in the console output explain the errors encountered. An alert is a fatal condition and prohibits the service from starting. A warning indicates a condition that is not fatal now but may become fatal in the target release. Fix both types of conditions before proceeding.
Optional: Split the load balancer configuration file Jump to heading
By default, the HAProxy Enterprise service loads only one configuration file, /etc/hapee-<VERSION>/hapee-lb.cfg. If you have a complex configuration and edit it yourself, you may want to consider splitting the configuration into multiple configuration files.
Info
You cannot split a configuration into multiple files if you use the Data Plane API to make configuration changes. The Data Plane API operates only on single-file configurations.
A multi-file configuration is typically used for load balancers that support multiple applications. In such a configuration, the default configuration file would contain the global directives shared by all applications, and the defaults, frontend, and backend sections for each application would be contained in their own configuration files. Thus, for example, if there were two applications, there might be one file for global directives, a second file containing the defaults, frontend, and backend sections for application A, and a third file containing the defaults, frontend, and backend sections for application B.
To split the load balancer configuration:
-
Create the directory
/etc/hapee-<VERSION>/lb-conf.d. For example:nixsudo mkdir /etc/hapee-3.2/lb-conf.d/nixsudo mkdir /etc/hapee-3.2/lb-conf.d/ -
In the
lb-conf.ddirectory, create a configuration file for one application, for example,app-A.cfg. -
Move the application A sections from the main configuration file,
/etc/hapee-<VERSION>/hapee-lb.cfg, to the application A configuration file/etc/hapee-<VERSION>/lb-conf.d/app-A.cfg. -
Repeat this process for the remaining applications.
Info
- Do not split configuration sections. A configuration section (such as
global,defaults,frontend, orbackend) must be completely contained in a single file and cannot be split across multiple files. - Configuration files must have the suffix
.cfg. - The lexical sort order of the names determines the order in which they are loaded at start time.
- Do not split configuration sections. A configuration section (such as
-
Edit the service environment file:
- On Debian/Ubuntu:
/etc/default/hapee-<VERSION>-lb - On other operating systems:
/etc/sysconfig/hapee-<VERSION>-lb
Change the
OPTIONSline so that it contains the following-fargument, which loads the files in thelb-conf.ddirectory when the HAProxy Enterprise service starts:hapee-3.2-lbtextOPTIONS="-f /etc/hapee-3.2/lb-conf.d/"hapee-3.2-lbtextOPTIONS="-f /etc/hapee-3.2/lb-conf.d/" - On Debian/Ubuntu:
-
Restart the service:
nixsudo systemctl restart hapee-3.2-lbnixsudo systemctl restart hapee-3.2-lb
With this configuration, when the load balancer starts, it first loads the default file containing the global section. Then it loads the files in the lb-conf.d directory in lexical sort order.
Validating the configuration Jump to heading
-
Use the
hapee-lbprogram’s-cflag to validate the configuration files in configurations split as described above.Depending on your version, the command’s output indicates that the file is valid in these ways:
- In version 2.8 and earlier, the command indicates a valid configuration by printing
Configuration file is validin addition to setting the zero return status. - In version 2.9 and later, the command sets the zero return status for a valid configuration but does not display a message. To display the message, include the
-Voption on the command line.
nixsudo /opt/hapee-3.2/sbin/hapee-lb -c -f /etc/hapee-3.2/hapee-lb.cfg -f /etc/hapee-3.2/lb-conf.d/ -Vnixsudo /opt/hapee-3.2/sbin/hapee-lb -c -f /etc/hapee-3.2/hapee-lb.cfg -f /etc/hapee-3.2/lb-conf.d/ -VAlerts and warnings that appear in the console output explain the errors encountered. An alert is a fatal condition and prohibits the service from starting. A warning indicates a condition that is not fatal now but may become fatal in the target release. Address all the errors until you receive the successful output:
Configuration file is valid. - In version 2.8 and earlier, the command indicates a valid configuration by printing
Do you have any suggestions on how we can improve the content of this page?