Core concepts
Overview
Use the HAProxy configuration file to define all aspects of the load balancer function, such as:
- Is the incoming stream treated as UDP, TCP, or HTTP?
- What sort of authentication is applied?
- Should supplemental security modules such as bot management, firewall, or captcha be applied?
- What about other supplemental modules, such as geolocation, device detection, or SNMP?
- Should metrics influence whether to deny or allow a request?
- Which backend servers should service the request?
- What log output do you need?
The configuration file can be simple or quite complex, depending on your needs.
Accessing the configuration file Jump to heading
:::tabs Configuration File#config-file-loc
@tab HAProxy Enterprise#haproxy-enterprise
The configuration file is here:
text
/etc/hapee-3.0/hapee-lb.cfg
text
/etc/hapee-3.0/hapee-lb.cfg
@tab HAProxy#haproxy
The configuration file is here:
text
/etc/haproxy/haproxy.cfg
text
/etc/haproxy/haproxy.cfg
@tab HAProxy ALOHA#haproxy-aloha
Open the LB Layer7 tab.
:::
Configuration file composition Jump to heading
An HAProxy configuration file is composed of sections like frontend
, backend
, defaults
, and global
.
In the example below you can see a basic configuration file’s layout that contains these four sections. Section headers begin at the start of a line and all configuration directives of a section should be indented for readability. Except for global
, you can set multiple sections of the same type, such as to load balance different websites and define different pools of backend servers.
haproxy
global# process-level settings go heredefaults# default settings go herefrontend listener# a frontend that accepts requests from clientsbackend webservers# servers that fulfill the requests
haproxy
global# process-level settings go heredefaults# default settings go herefrontend listener# a frontend that accepts requests from clientsbackend webservers# servers that fulfill the requests
You can enable extra functionality by using the various other sections, such as mailers
, peers
, and resolvers
, which we describe in other parts of this guide.
See also Jump to heading
Do you have any suggestions on how we can improve the content of this page?