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
5 changes: 5 additions & 0 deletions jobs/haproxy/spec
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ properties:
default: ~
ha_proxy.backend_ca_file:
description: "Optional SSL CA certificate chain (PEM file) concatenated together for backend SSL servers, only used when one of the `backend_ssl` options is set to `verify`"
ha_proxy.enable_health_check_http:
description: "Optionally enable http health-check on `haproxy_ip:8080/health`. It shows `200 OK` if >0 backend servers are up."
default: false
ha_proxy.disable_http:
description: "Disable port 80 traffic"
default: false
Expand Down Expand Up @@ -189,6 +192,8 @@ properties:
# Setting `verify` requires `ha_proxy.backend_ca_file` key to be set.
backend_verifyhost: example.com # optional - hostname to verify in the x509 certificate subject for SSL-enabled backend servers
# only used if backend_ssl: `verify` is set
health_check_http: 4444 # optional port number - if provided a heath check http site is created at `haproxy_ip:4444/health`.
# It shows `200 OK` if >0 backend servers are up.
ha_proxy.tcp_link_port:
description: "Port haproxy should listen on when using the tcp_backend link"
ha_proxy.resolvers:
Expand Down
21 changes: 19 additions & 2 deletions jobs/haproxy/templates/haproxy.config.erb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ listen stats_<%= proc %>
<% end %>
<% end %>

<% if p("ha_proxy.enable_health_check_http") %>
listen health_check_http_url
bind :8080
mode http
monitor-uri /health
acl http-routers_down nbsrv(http-routers) eq 0
monitor fail if http-routers_down
<% end %>

<%# HTTP Frontend %>

<%
Expand Down Expand Up @@ -351,7 +360,7 @@ if tcp_proxy["backend_port"]
backend_port = tcp_proxy["backend_port"]
end %>

<% tcp_proxy["backend_servers"].each_with_index do |ip, index| %>
<% tcp_proxy["backend_servers"].each_with_index do |ip, index| %>
server node<%= index %> <%= ip %>:<%= backend_port %> <% if_p("ha_proxy.resolvers") do -%>
resolvers default <% end -%> check inter 1000 <% if tcp_proxy["backend_ssl"] then -%>
<% if tcp_proxy["backend_ssl"].downcase == "verify" then -%>
Expand All @@ -360,6 +369,14 @@ end %>
<% elsif tcp_proxy["backend_ssl"].downcase == "noverify" then -%>
ssl verify none <% end -%>
<% end -%>
<% end -%>
<% end -%>

<% if tcp_proxy["health_check_http"] then %>
listen health_check_http_tcp-<%= tcp_proxy["name"] %>
bind :<%= tcp_proxy["health_check_http"] %>
mode http
monitor-uri /health
acl tcp-<%= tcp_proxy["name"] %>-routers_down nbsrv(tcp-<%= tcp_proxy["name"] %>) eq 0
monitor fail if tcp-<%= tcp_proxy["name"] %>-routers_down
<% end -%>
<% end -%>