Cookbooks
haproxy
documentation
Haproxy Listen

Back To Resource List (opens in a new tab)


haproxy_listen

Listen defines a complete proxy with its frontend and backend parts combined in one section.

It is generally useful for TCP-only traffic.

Introduced: v4.0.0

Actions

  • :create
  • :delete

Properties

This resource also uses the following partial resources:

NameTypeDefaultDescriptionAllowed Values
bindString, Hash0.0.0.0:80String - sets as given. Hash - joins with a space
modeStringNoneSet the running mode or protocol of the instancehttp, tcp
maxconnIntegerNoneSets the maximum per-process number of concurrent connections
reqrepString, ArrayNoneReplace a regular expression with a string in an HTTP request line
reqirepString, ArrayNonereqrep ignoring case
default_backendStringNoneSpecify the backend to use when no "use_backend" rule has been matched
use_backendArrayNoneSwitch to a specific backend if/unless an ACL-based condition is matched
http_requestArrayNoneSwitch to a specific backend if/unless an ACL-based condition is matched
http_responseArrayNoneSwitch to a specific backend if/unless an ACL-based condition is matched
aclArrayNoneAccess control list itemsAllowed HAProxy acl values
serverArrayNoneServers the listen section routes to
statsHashNoneEnable stats with various options
hash_typeStringNoneSpecify a method to use for mapping hashes to serversconsistent, map-based

Examples

haproxy_listen 'admin' do
  bind '0.0.0.0:1337'
  mode 'http'
  stats uri: '/',
        realm: 'Haproxy-Statistics',
        auth: 'user:pwd'
  http_request 'add-header X-Proto http'
  http_response 'set-header Expires %[date(3600),http_date]'
  default_backend 'servers'
  extra_options('bind-process' => 'odd')
  server ['admin0 10.0.0.10:80 check weight 1 maxconn 100',
          'admin1 10.0.0.10:80 check weight 1 maxconn 100']
end