Skip to content

Commit

Permalink
feat(loadbalancer): working on noble
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobCoffee committed Jul 30, 2024
1 parent e94c512 commit af57a6f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SERVERS = [
"docs",
"downloads",
"hg",
{:name => "loadbalancer", :ports => [20000, 20001, 20002, 20003, 20004, 20005, 20010, 20011]},
{:name => "loadbalancer", :codename => "noble", :ports => [20000, 20001, 20002, 20003, 20004, 20005, 20010, 20011]},
"mail",
"moin",
"planet",
Expand Down
21 changes: 20 additions & 1 deletion salt/haproxy/config/haproxy.cfg.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ frontend main
capture request header X-Forwarded-For len 64

acl letsencrypt-well-known-acl path_beg /.well-known/acme-challenge/
use_backend letsencrypt-well-known if letsencrypt-well-known-acl

# Determine if this request has TLS on the client side or not.
acl is_tls dst_port 19001
Expand All @@ -142,6 +141,8 @@ frontend main
# Redirect all HTTP traffic to HTTPS
redirect code 301 scheme https if !is_tls !letsencrypt-well-known-acl

use_backend letsencrypt-well-known if letsencrypt-well-known-acl

# Dispatch to the redirect backend for any redirects we have, we're going
# to do this here after the HTTP -> HTTPS redirect even though this will
# result in an extra redirect because we want to give this domain a chance
Expand Down Expand Up @@ -215,7 +216,25 @@ backend redirect
{% for service, config in haproxy.services.items() %}
backend {{ service }}
{% if config.get("check") -%}
{% if grains["oscodename"] != "noble" -%}
option httpchk {{ config.check }}
{%- else -%}
# Noble Config using the newer http-check syntax
# We need to split the check into parts to handle the extra things
# ...maybe there is a better way to do this?
{% set check_parts = config.check.split(' ', 2) -%}
{% set method = check_parts[0] -%}
{% set path = check_parts[1] -%}
{% if check_parts|length > 2 -%}
{% set extra = check_parts[2].split('\r\n') -%}
{% set version = extra[0] -%}
{% set headers = extra[1:] -%}
{% endif -%}
http-check send meth {{ method }} uri {{ path }} ver {{ version }}
{%- for header in headers %}
http-check send hdr {{ header.replace(':\\ ', ': ') }}
{%- endfor %}
{%- endif %}
{%- endif %}

# http://gnuterrypratchett.com/
Expand Down

0 comments on commit af57a6f

Please sign in to comment.