Skip to content

Commit

Permalink
Add secure cookies for SSL frontends.
Browse files Browse the repository at this point in the history
  • Loading branch information
kwatson committed Sep 27, 2023
1 parent f063bc3 commit a4238a6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion app/views/api/stacks/load_balancers/haproxy/_backend-http.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% load_balancer.container_services.each do |service| %>
<% next if service.containers.empty? %>
<% next if service.containers.empty? %>
<% service.ingress_rules.where(external_access: true, proto: 'http').each do |ingress| %>
backend <%= Digest::MD5.hexdigest("#{service.name}#{ingress.id}") %>
mode http
Expand All @@ -16,3 +16,22 @@ backend <%= Digest::MD5.hexdigest("#{service.name}#{ingress.id}") %>
<% end %>
<% end %>
<% end %>

<% load_balancer.container_services.each do |service| %>
<% next if service.containers.empty? %>
<% service.ingress_rules.where(external_access: true, proto: 'http').each do |ingress| %>
backend S_<%= Digest::MD5.hexdigest("#{service.name}#{ingress.id}") %>
mode http
option redispatch
option httpchk HEAD /
cookie SERVERID insert indirect nocache httponly secure
<% service.containers.each do |container| %>
<% next if container.ip_address.nil? %>
<% if !load_balancer.direct_connect && (node != container.node) %>
server <%= container.name %> <%= container.node.primary_ip %>:443 ssl verify none maxconn <%= load_balancer.maxconn_c %> maxqueue <%= load_balancer.max_queue %> cookie s<%= container.name.split('-').last %>
<% else %>
server <%= container.name %> <%= container.ip_address.ipaddr %>:<%= ingress.port %> maxconn <%= load_balancer.maxconn_c %> maxqueue <%= load_balancer.max_queue %> cookie s<%= container.name.split('-').last %><% if ingress.backend_ssl %> ssl verify none<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ frontend https
<% if domain.enable_hsts_header? %>
http-response set-header Strict-Transport-Security "max-age=16000000; preload;" if host_rule_<%= index %>
<% end %>
use_backend <%= Digest::MD5.hexdigest("#{service.name}#{ingress.id}") %> if host_rule_<%= index %>
use_backend S_<%= Digest::MD5.hexdigest("#{service.name}#{ingress.id}") %> if host_rule_<%= index %>
<% index += 1 %>
<% end %>
<% end %>
Expand Down

0 comments on commit a4238a6

Please sign in to comment.