anchor.diff:  backend http-routers
       mode http
       balance roundrobin
  -    <% if p("ha_proxy.compress_types") != "" -%>
  +  <%- if p("ha_proxy.compress_types") != "" -%>
       compression algo gzip
       compression type <%= p("ha_proxy.compress_types") %>
  -    <% end -%>
  -
  -    <%
  -    backend_servers = []
  -    backend_port = nil
  -    if_link("http_backend") do |backend|
  -        backend_servers = backend.instances.map(&:address)
  -        backend_port = backend.p("port", p("ha_proxy.backend_port"))
  -    end.else_if_p("ha_proxy.backend_servers") do |servers|
  -        backend_servers = servers
  -        backend_port = p("ha_proxy.backend_port")
  +  <%- end -%>
  +<%
  +  backend_servers = []
  +  backend_port = nil
  +  if_link("http_backend") do |backend|
  +    backend_servers = backend.instances.map(&:address)
  +    backend_port = backend.p("port", p("ha_proxy.backend_port"))
  +  end.else_if_p("ha_proxy.backend_servers") do |servers|
  +    backend_servers = servers
  +    backend_port = p("ha_proxy.backend_port")
  +  end
  +  resolvers = ""
  +  if_p("ha_proxy.resolvers") do
  +    resolvers = "resolvers default "
  +  end
  +  backend_crt = ""
  +  if_p("ha_proxy.backend_crt") do
  +    backend_crt = "crt /var/vcap/jobs/haproxy/config/backend-crt.pem "
  +  end
  +  backend_ssl = ""
  +  if p("ha_proxy.backend_ssl").downcase == "verify" then
  +    backend_ssl = "ssl verify required ca-file /var/vcap/jobs/haproxy/config/backend-ca-certs.pem "
  +    if_p("ha_proxy.backend_ssl_verifyhost") do | verify_hostname |
  +      backend_ssl += "verifyhost #{verify_hostname} "
       end
  -    -%>
  -
  -    <% backend_servers.each_with_index do |ip, index| -%>
  -        server node<%= index %> <%= ip %>:<%= backend_port %> <% if_p("ha_proxy.resolvers") do -%>
  -        resolvers default <% end -%>
  -        <% if_p("ha_proxy.backend_crt") do -%> crt  /var/vcap/jobs/haproxy/config/backend-crt.pem <% end -%>
  -        check inter 1000 <% if p("ha_proxy.backend_ssl").downcase == "verify" then -%>
  -        ssl verify required ca-file /var/vcap/jobs/haproxy/config/backend-ca-certs.pem <% if_p("ha_proxy.backend_ssl_verifyhost") do | verify_hostname | -%>
  -        verifyhost <%= verify_hostname %> <% end -%>
  -        <% elsif p("ha_proxy.backend_ssl").downcase == "noverify" then -%>
  -        ssl verify none <% end -%>
  -
  -    <% end -%>
  -# }}}
  +  elsif p("ha_proxy.backend_ssl").downcase == "noverify" then
  +    backend_ssl = "ssl verify none "
  +  end
  +-%>
  +  <%- backend_servers.each_with_index do |ip, index| -%>
  +    server node<%= index %> <%= ip %>:<%= backend_port -%> <%= resolvers -%><%= backend_crt -%>check inter 1000 <%= backend_ssl %>
  +  <%- end -%>
  +# }}}
  +
   # Routed Backends {{{
   <% p('ha_proxy.routed_backend_servers').each do |prefix, data| -%>
  -<% prefix_hash = (Digest::SHA256.hexdigest prefix.to_s)[0..5] -%>
  +  <%- prefix_hash = (Digest::SHA256.hexdigest prefix.to_s)[0..5] -%>
   backend http-routed-backend-<%= prefix_hash %>
       mode http
       balance roundrobin
  -    <% if p("ha_proxy.compress_types") != "" -%>
  +  <%- if p("ha_proxy.compress_types") != "" -%>
       compression algo gzip
       compression type <%= p("ha_proxy.compress_types") %>
  -    <% end -%>
  -    <% data["servers"].each_with_index do |ip, index| -%>
  -        server node<%= index %> <%= ip %>:<%= data["port"] %> <% if_p("ha_proxy.resolvers") do -%>
  -        resolvers default <% end -%>
  -        check inter 1000 <% if data["backend_ssl"] then -%>
  -           <% if data["backend_ssl"].downcase == "verify" then -%>
  -             ssl verify required ca-file /var/vcap/jobs/haproxy/config/backend-ca-certs.pem <% if data["backend_verifyhost"] then -%>
  -             verifyhost <%= data["backend_verifyhost"] %> <% end -%>
  -           <% elsif data["backend_ssl"].downcase == "noverify" then -%>
  -             ssl verify none <% end -%>
  -        <% end -%>
  -
  -    <% end -%>
  -<% end -%>
  -# }}}
  +  <%- end -%>
  +<%
  +  resolvers = ""
  +  if_p("ha_proxy.resolvers") do
  +    resolvers = "resolvers default "
  +  end
  +  backend_ssl = ""
  +  if data["backend_ssl"] then
  +    if data["backend_ssl"].downcase == "verify" then
  +      backend_ssl = "ssl verify required ca-file /var/vcap/jobs/haproxy/config/backend-ca-certs.pem "
  +      if data["backend_verifyhost"] then
  +        backend_ssl += "verifyhost #{data["backend_verifyhost"]} "
  +      end
  +    elsif data["backend_ssl"].downcase == "noverify" then
  +      backend_ssl = "ssl verify none "
  +    end
  +  end
  +-%>
  +  <%- data["servers"].each_with_index do |ip, index| -%>
  +    server node<%= index %> <%= ip %>:<%= data["port"] %> <%= resolvers -%>check inter 1000 <%= backend_ssl %>
  +  <%- end -%>
  +<% end -%>
  +# }}}
  +
   # TCP Routing  {{{
   <% if_link("tcp_router") do |tcp_router| -%>
  +
   frontend cf_tcp_routing
  -  mode tcp
  -  bind <%= p("ha_proxy.binding_ip") %>:<%= p("ha_proxy.tcp_routing.port_range") %>
  -  default_backend cf_tcp_routers
  +    mode tcp
  +    bind <%= p("ha_proxy.binding_ip") %>:<%= p("ha_proxy.tcp_routing.port_range") %>
  +    default_backend cf_tcp_routers
  +
   backend cf_tcp_routers
  -  mode tcp
  -  <% tcp_router.instances.each_with_index do |instance, index| %>
  -  server node<%= index %> <%= instance.address %> check port 80 inter 1000
  -  <% end -%>
  +    mode tcp
  +  <%- tcp_router.instances.each_with_index do |instance, index| -%>
  +    server node<%= index %> <%= instance.address %> check port 80 inter 1000
  +  <%- end -%>
   <% end -%>
   
   # TCP Backends
  
positive.code: # Accept Proxy {{{
  accept_proxy = ""
  if p("ha_proxy.accept_proxy")
      accept_proxy = "accept-proxy"
  end
  # }}}
  # Global SSL Flags {{{
  ssl_flags = "no-sslv3"
  if p("ha_proxy.disable_tls_10")
  	ssl_flags = "#{ssl_flags} no-tlsv10"
  end
  if p("ha_proxy.disable_tls_11")
  	ssl_flags = "#{ssl_flags} no-tlsv11"
  end
  if p("ha_proxy.disable_tls_tickets")
  	ssl_flags = "#{ssl_flags} no-tls-tickets"
  end
  # }}}
  # TLS Bind Options {{{
  
negative.code: <% require "digest" -%>
  <%# Ruby Variables to make the template more readable -%>
  <%
  # Stats Binding Variables {{{
  