Skip to content

sous-chefs/haproxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

8d6fcd5 · Dec 9, 2024
Nov 5, 2024
Mar 15, 2023
Dec 9, 2024
Jun 27, 2017
Jan 31, 2024
Dec 9, 2024
Jan 31, 2024
Dec 9, 2024
Dec 9, 2024
Oct 8, 2020
May 22, 2024
Apr 13, 2020
Oct 8, 2020
Nov 18, 2024
Feb 6, 2020
Feb 20, 2019
Apr 7, 2023
Jan 31, 2024
Mar 15, 2023
Mar 29, 2021
Dec 9, 2024
Dec 8, 2016
May 22, 2024
Jan 31, 2024
Jan 31, 2024
Feb 28, 2012
Jan 31, 2024
May 22, 2024
Apr 21, 2022
Nov 18, 2024
Apr 7, 2023
Jul 15, 2024
Jan 31, 2024
Dec 9, 2024
Nov 1, 2023

Repository files navigation

haproxy Cookbook

CI State Cookbook Version OpenCollective OpenCollective License

Installs and configures HAProxy.

Maintainers

This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If you’d like to know more please visit sous-chefs.org or come chat with us on the Chef Community Slack in #sous-chefs.

Requirements

  • HAProxy stable or LTS
  • Chef 13.9+

Platforms

This cookbook officially supports and is tested against the following platforms:

  • debian: 9 & 10
  • ubuntu: 20.04 & 21.04
  • centos: 7 & 8
  • centos-stream: 8
  • fedora: latest
  • amazonlinux: 2

PRs are welcome to add support for additional platforms.

Examples

Please check for working examples in the test cookbook.

Common Resource Features

HAProxy has many configurable options available, this cookbook makes the most popular options available as resource properties.

If you wish to use a HAProxy property that is not listed the extra_options hash is available to take in any number of additional values.

For example, the ability to disable listeners is not provided out of the box. Further examples can be found in either test/fixtures/recipes or spec/test/recipes. If you have questions on how this works or would like to add more examples so it is easier to understand, please come talk to us on the Chef Community Slack on the #sous-chefs channel.

haproxy_listen 'disabled' do
  bind '0.0.0.0:1337'
  mode 'http'
  extra_options('disabled': '')
end

The extra_options hash is of String => String or String => Array. When an Array value is provided. The values are looped over mapping the key to each value in the config.

For example:

haproxy_listen 'default' do
  extra_options(
    'http-request' => [ 'set-header X-Public-User yes', 'del-header X-Bad-Header' ]
    )
end

Becomes:

listen default
  ...
  http-request set-header X-Public-User yes
  http-request del-header X-Bad-Header

Resources

Configuration Validation

The haproxy.cfg file has a few specific rule orderings that will generate validation errors if not loaded properly. If using any combination of the below rules, avoid the errors by loading the rules via extra_options to specify the top down order as noted below in config file.

frontend & listen

  tcp-request connection
  tcp-request session
  tcp-request content
  monitor fail
  http-request
  reqxxx (any req excluding reqadd, e.g. reqdeny, reqallow)
  reqadd
  redirect
  use_backend
  extra_options(
    'tcp-request' => 'connection set-src src,ipmask(24)',
    'reqdeny' => '^Host:\ .*\.local',
    'reqallow' => '^Host:\ www\.',
    'use_backend' => 'dynamic'
  )

backend

  http-request
  reqxxx (any req excluding reqadd, e.g. reqdeny, reqallow)
  reqadd
  redirect
  extra_options(
    'http-request' => 'set-path /%[hdr(host)]%[path]',
    'reqdeny' => '^Host:\ .*\.local',
    'reqallow' => '^Host:\ www\.',
    'redirect' => 'dynamic'
  )

Contributors

This project exists thanks to all the people who contribute.

Backers

Thank you to all our backers!

https://opencollective.com/sous-chefs#backers

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website.

https://opencollective.com/sous-chefs/sponsor/0/website https://opencollective.com/sous-chefs/sponsor/1/website https://opencollective.com/sous-chefs/sponsor/2/website https://opencollective.com/sous-chefs/sponsor/3/website https://opencollective.com/sous-chefs/sponsor/4/website https://opencollective.com/sous-chefs/sponsor/5/website https://opencollective.com/sous-chefs/sponsor/6/website https://opencollective.com/sous-chefs/sponsor/7/website https://opencollective.com/sous-chefs/sponsor/8/website https://opencollective.com/sous-chefs/sponsor/9/website