Cookbooks
haproxy
documentation
Haproxy Backend

Back To Resource List (opens in a new tab)


haproxy_backend

Backend describes a set of servers to which the proxy will connect to forward incoming connections.

Introduced: v4.0.0

Actions

  • :create
  • :delete

Properties

This resource also uses the following partial resources:

NameTypeDefaultDescriptionAllowed Values
modeStringNoneSet the running mode or protocol of the instancehttp, tcp
serverString, ArrayNoneServers the backend routes to
tcp_requestString, ArrayNoneHAProxy tcp-request settings
reqrepString, ArrayNoneReplace a regular expression with a string in an HTTP request line
reqirepString, ArrayNonereqrep ignoring case
aclArrayNoneAccess control list itemsAllowed HAProxy acl values
optionArrayNoneArray of HAProxy option directives
extra_optionsHashNoneUsed for setting any HAProxy directives
hash_typeStringNoneSpecify a method to use for mapping hashes to serversconsistent, map-based

Examples

haproxy_backend 'servers' do
  server ['server1 127.0.0.1:8000 maxconn 32']
end
haproxy_backend 'tiles_public' do
  server ['tile0 10.0.0.10:80 check weight 1 maxconn 100',
          'tile1 10.0.0.10:80 check weight 1 maxconn 100']
  tcp_request ['content track-sc2 src',
               'content reject if conn_rate_abuse mark_as_abuser']
  option %w(httplog dontlognull forwardfor)
  acl ['conn_rate_abuse sc2_conn_rate gt 3000',
       'data_rate_abuse sc2_bytes_out_rate gt 20000000',
       'mark_as_abuser sc1_inc_gpc0 gt 0',
     ]
  extra_options(
    'stick-table' => 'type ip size 200k expire 2m store conn_rate(60s),bytes_out_rate(60s)',
    'http-request' => 'set-header X-Public-User yes'
  )
end