diff options
| -rw-r--r-- | frontends/Rexfile | 12 | ||||
| -rw-r--r-- | frontends/etc/relayd.conf.tpl | 17 |
2 files changed, 22 insertions, 7 deletions
diff --git a/frontends/Rexfile b/frontends/Rexfile index 11ce519..ba5238b 100644 --- a/frontends/Rexfile +++ b/frontends/Rexfile @@ -46,6 +46,17 @@ $ips{current_master}{fqdn} = 'fishfinger.' . $ips{domain}; $ips{current_standby} = $ips{blowfish}; $ips{current_standby}{fqdn} = 'blowfish.' . $ips{domain}; +# Gather IPv4 addresses based on hostname. +our $ipv4address = sub { + my $hostname = shift; + my $ip = $ips{$hostname}{ipv4}; + unless ( defined $ip ) { + Rex::Logger::info( "Unable to determine IPv4 address for $hostname", 'error' ); + return '127.0.0.1'; + } + return $ip; +}; + # Gather IPv6 addresses based on hostname. our $ipv6address = sub { my $hostname = shift; @@ -313,6 +324,7 @@ task 'relayd', file '/etc/relayd.conf', content => template( './etc/relayd.conf.tpl', + ipv4address => $ipv4address, ipv6address => $ipv6address, f3s_hosts => \@f3s_hosts, acme_hosts => \@acme_hosts diff --git a/frontends/etc/relayd.conf.tpl b/frontends/etc/relayd.conf.tpl index 159b097..7c38464 100644 --- a/frontends/etc/relayd.conf.tpl +++ b/frontends/etc/relayd.conf.tpl @@ -65,14 +65,17 @@ http protocol "https" { # For f3s hosts: use relay-level failover (f3s -> localhost backup) # Registry is special: needs explicit routing to port 30001 - <% for my $host (@$f3s_hosts) { for my $prefix (@prefixes) { - if ($host eq 'registry.f3s.buetow.org') { -%> + <% for my $host (@$f3s_hosts) { + for my $prefix (@prefixes) { + if ($host eq 'registry.f3s.buetow.org') { + -%> match request header "Host" value "<%= $prefix.$host -%>" forward to <f3s_registry> - <% } - elsif ($host eq 'jellyfin.f3s.buetow.org') { -%> + <% } elsif ($host eq 'jellyfin.f3s.buetow.org') { + -%> match request header "Host" value "<%= $prefix.$host -%>" forward to <f3s_jellyfin> - <% } - } } -%> + <% } + } + } -%> # Add cache-control headers to f3s fallback pages (served from localhost when cluster is down) match response header set "Cache-Control" value "no-cache, no-store, must-revalidate" @@ -81,7 +84,7 @@ http protocol "https" { } relay "https4" { - listen on <%= $vio0_ip %> port 443 tls + listen on <%= $ipv4address->($hostname) %> port 443 tls protocol "https" persist timeout connect 10s |
