From 916f99f92c7e2ec3a34e45dcf3c98d3c023bc2e2 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 3 Dec 2025 01:29:35 +0200 Subject: initial f3s fallback --- frontends/Rexfile | 13 ++++++++++++- frontends/etc/httpd.conf.tpl | 12 ++++++++++++ frontends/etc/relayd.conf.tpl | 6 ++++-- 3 files changed, 28 insertions(+), 3 deletions(-) (limited to 'frontends') diff --git a/frontends/Rexfile b/frontends/Rexfile index 95e788a..2964004 100644 --- a/frontends/Rexfile +++ b/frontends/Rexfile @@ -234,7 +234,11 @@ task 'httpd', append_if_no_such_line '/etc/rc.conf.local', 'httpd_flags='; file '/etc/httpd.conf', - content => template( './etc/httpd.conf.tpl', acme_hosts => \@acme_hosts ), + content => template( + './etc/httpd.conf.tpl', + acme_hosts => \@acme_hosts, + f3s_hosts => \@f3s_hosts + ), owner => 'root', group => 'wheel', mode => '644', @@ -243,6 +247,13 @@ task 'httpd', file '/var/www/htdocs/buetow.org', ensure => 'directory'; file '/var/www/htdocs/buetow.org/self', ensure => 'directory'; + file '/var/www/htdocs/f3s_fallback', ensure => 'directory'; + file '/var/www/htdocs/f3s_fallback/index.html', + source => './var/www/htdocs/f3s_fallback/index.html', + owner => 'root', + group => 'wheel', + mode => '644'; + # For failover health-check. file '/var/www/htdocs/buetow.org/self/index.txt', ensure => 'file', diff --git a/frontends/etc/httpd.conf.tpl b/frontends/etc/httpd.conf.tpl index d7095a6..e4d7b84 100644 --- a/frontends/etc/httpd.conf.tpl +++ b/frontends/etc/httpd.conf.tpl @@ -161,6 +161,18 @@ server "<%= $prefix %>ecat.buetow.org" { } <% } -%> +# Fallback for f3s hosts +<% for my $host (@$f3s_hosts) { for my $prefix (@prefixes) { -%> +server "<%= $prefix.$host %>" { + listen on * port 8080 + log style forwarded + location * { + root "/htdocs/f3s_fallback" + directory auto index + } +} +<% } } -%> + # Defaults server "default" { listen on * port 80 diff --git a/frontends/etc/relayd.conf.tpl b/frontends/etc/relayd.conf.tpl index 68b9e80..93af3e4 100644 --- a/frontends/etc/relayd.conf.tpl +++ b/frontends/etc/relayd.conf.tpl @@ -40,10 +40,12 @@ http protocol "https" { pass header "Sec-WebSocket-Protocol" <% for my $host (@$f3s_hosts) { for my $prefix (@prefixes) { -%> + # Fallback to localhost + match request header "Host" value "<%= $prefix.$host -%>" forward to <% if ($host eq 'registry.f3s.buetow.org') { -%> - match request quick header "Host" value "<%= $prefix.$host -%>" forward to + match request header "Host" value "<%= $prefix.$host -%>" forward to <% } else { -%> - match request quick header "Host" value "<%= $prefix.$host -%>" forward to + match request header "Host" value "<%= $prefix.$host -%>" forward to <% } } } -%> } -- cgit v1.2.3