Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion jobs/haproxy/spec
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,15 @@ properties:
ha_proxy.backend_config:
description: |
Raw HAProxy config that will be added to the default HTTP + routed HTTP backend definitions, provided either as a multiline text blob or as an array of lines.

ha_proxy.backend_config_targeted:
description: |
A map of existing backends which enables more fine-grained configuration of the backend.
example:
backend_config_targeted:
http-routers-http1: |
http-reuse aggressive
http-routers-http2: |
http-reuse safe
ha_proxy.custom_http_error_files:
description: |
A map of status codes to errorfile contents
Expand Down
7 changes: 7 additions & 0 deletions jobs/haproxy/templates/haproxy.config.erb
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,13 @@ backend <%= backend[:name] %>
<%- if properties.ha_proxy.backend_config -%>
<%= format_indented_multiline_config(p("ha_proxy.backend_config")) %>
<%- end -%>
<%- backend_configs = p('ha_proxy.backend_config_targeted', {}) -%>
<%- backend_configs.keys.each do |backend_name| -%>
<%- if backend[:name] == backend_name -%>
<%= format_indented_multiline_config(backend_configs[backend_name]) -%>
<%- end -%>
<%- end -%>

<%- p('ha_proxy.custom_http_error_files', {}).keys.each do |status_code| -%>
errorfile <%= status_code %> /var/vcap/jobs/haproxy/errorfiles/custom<%=status_code%>.http
<%- end -%>
Expand Down
49 changes: 49 additions & 0 deletions spec/haproxy/templates/haproxy_config/backend_http_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,55 @@
end
end

context 'when ha_proxy.backend_config_targeted is h1' do
let(:properties) do
{
'backend_config_targeted' => {
'http-routers-http1' => 'http-reuse aggressive'
}
}
end

it 'includes the config' do
expect(backend_http1).to include('http-reuse aggressive')
end
end

context 'when ha_proxy.backend_config_targeted is h2' do
let(:properties) do
{
'enable_http2' => true,
'backend_ssl' => 'verify',
'backend_config_targeted' => {
'http-routers-http2' => 'http-reuse safe'
}
}
end

it 'includes the config' do
expect(backend_http2).to include('http-reuse safe')
end
end

context 'when ha_proxy.backend_config_targeted is h1 and h2' do
let(:properties) do
{
'enable_http2' => true,
'backend_ssl' => 'verify',
'disable_backend_http2_websockets' => true,
'backend_config_targeted' => {
'http-routers-http1' => 'http-reuse aggressive',
'http-routers-http2' => 'http-reuse safe'
}
}
end

it 'includes the config' do
expect(backend_http1).to include('http-reuse aggressive')
expect(backend_http2).to include('http-reuse safe')
end
end

context 'when ha_proxy.custom_http_error_files is provided' do
let(:properties) do
{
Expand Down