Logo

Command Palette

Search for a command to run...

HAProxy Configuration

HAProxy

You can use your Manifest file to configure and define any HAProxy load balancers deployed by Cloud 66. These changes will be either be applied when you redeploy an application with more than one server, rebuild HAProxy or edit HAProxy CustomConfig.

Because HAProxy load balancers are not "cloud native", you will need to specify the server configuration in the same YAML node as your HAProxy settings. The server configuration settings are :

Server optionsApplied onDescription
key_nameDefault
regionDigitalOcean's region
sizeThe size of the instance
unique_nameName of the instance

The following HAProxy settings are available via the Manifest file:

OptionApplied onDescription
balanceThe load balancing strategy. Valid values: roundrobin, leastconn or source
errorfile_*ERROR_CODE*Location of your own custom error page(s) to serve in the case of receiving a HTTP error code on the load balancer. You can configure one page per error code.
haproxy_passwordThe password for your HAProxy stats interface.
haproxy_usernameThe username for your HAProxy stats interface.
httpchkThe URL visited to check your server health
wait_after_adding_serversThe time (in seconds) we will wait after adding a server back to the load balancer before we begin routing traffic to that server. Read our in-depth guide on configuration lag for more details.
wait_after_removing_serversThe time (in seconds) we will wait after adding a server back to the load balancer before we begin routing traffic to that server. Read our in-depth guide on configuration lag for more details.

Refer to the HAProxy documentation for more information

Example YAML for HAProxy load balancers

load_balancer:
  servers:
  - server:
    unique_name: bananana
    size: 1gb
    region: ams2
    vendor: digitalocean
    key_name: Default
  configuration:
    httpchk: HEAD / HTTP/1.1\\r\\nHost:haproxy  #default value
    balance: roundrobin #default value
    errorfile_400: /etc/haproxy/errors/400.http
    errorfile_403: /etc/haproxy/errors/403.http
    errorfile_500: /etc/haproxy/errors/500.http
    errorfile_504: /etc/haproxy/errors/504.https
    wait_after_adding_servers: 30 # default is 0
    wait_after_removing_servers: 10 # default is 0

Automatic endpoint test

Load balancers periodically check the health of your servers by connecting to a URL endpoint. If the server responds with an HTTP 200 OK status, it is considered healthy. The httpchk setting allows you to specify which URL path should be checked.

The default value is HEAD / HTTP/1.1\\r\\nHost:haproxy but you can customize it to any valid endpoint in your application that returns a 200 status when healthy.