Skip to content
This repository was archived by the owner on Jan 21, 2022. It is now read-only.
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
8 changes: 7 additions & 1 deletion jobs/haproxy/monit
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<% if p("cc.allow_app_ssh_access") %>
<%
has_link = false
%>

<% if p("cc.allow_app_ssh_access") && !has_link %>
<% if_link("ssh_proxy") { }.else do %>
check process consul_template
with pidfile /var/vcap/sys/run/consul_template/pid
start program "/var/vcap/jobs/haproxy/bin/consul_template_ctl start"
Expand All @@ -12,6 +17,7 @@ check file haproxy_config
group vcap
depends on haproxy
<% end %>
<% end %>

check process haproxy
with pidfile /var/vcap/sys/run/haproxy/pid
Expand Down
5 changes: 5 additions & 0 deletions jobs/haproxy/spec
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ templates:
consul_template_ctl: bin/consul_template_ctl
cert.pem.erb: config/cert.pem

consumes:
- name: ssh_proxy
type: ssh_proxy
optional: true

properties:
ha_proxy.ssl_pem:
description: "SSL certificate (PEM file)"
Expand Down
16 changes: 16 additions & 0 deletions jobs/haproxy/templates/haproxy.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,19 @@ backend tcp-routers
<% p("router.servers").each_with_index do |ip, index| %>
server node<%= index %> <%= ip %>:<%= p("router.port") %> check inter 1000
<% end %>

<% if p("cc.allow_app_ssh_access") %>
<% if_link("ssh_proxy") do |ssh_proxy| %>
frontend ssh
mode tcp
bind :<%= p("app_ssh.port") %>
default_backend ssh

backend ssh
mode tcp
option tcp-check
balance leastconn<% ssh_proxy.instances.map do |instance| %>
server <%= instance.id %> <%= instance.address %>:2222 check<% end %>
timeout server 2h
<% end %>
<% end %>