The proposed rules don't seem to change relayd(8)'s behaviour.
It keeps sending HTTP traffic to the primary server and fail when it is
down. The secondary / fallback server is never used.
Starting status:
relayd[26195]: host 192.0.2.7, check http code (14ms,http code ok),
state unknown -> up, availability 100.00%
relayd[26195]: host 192.0.2.4, check http code (44ms,http code ok),
state unknown -> up, availability 100.00%
Stopping the backend server:
*relayd[21988]: host 192.0.2.4, check http code (3ms,http code
malformed), state up -> down, availability 95.65%
relayd[54506]: host 192.0.2.4, check http code (1ms,tcp connect failed),
state up -> down, availability 99.44%*
HTTP request while primary host is down:
relayd[63036]: relay www4tls, session 6 (1 active), example, 1.2.3.4 ->
:0, session failed, [ww.example/] [Host: www.example] [User-Agent:
curl/7.81.0] GET
Le 13/02/2024 à 04:29, l...@trungnguyen.me a écrit :
Hi
On February 13, 2024 12:20:26 AM UTC, Joel Carnat <j...@carnat.net> wrote:
Hello,
I'm trying to configure relayd(8) to use tags, to allow legit host names only
and modify HTTP headers, and fallback. But I can't have it working properly.
Using such a configuration:
#-8<-------
table <primary> { 192.0.2.4 }
table <fallback> { 192.0.2.7}
http protocol www {
block
match request header "Host" value "www.example" tag "example"
pass request tagged "example" forward to <primary>
Try:
match request header "Host" value "www.example" tag example
pass forward to <primary> tagged example
}
relay www {
listen on 192.0.2.30 port 80
protocol www
forward to <primary> port 80 check http "/" code 200
forward to <fallback> port 80
}
#-8<-------
forwards all tagged HTTP traffic to the primary server. But if it is turned
off, relayd(8) only replies with error rather than sending the traffic to the
fallback server.
What errors are you having?
Removing tags and using a simple "pass" directive in protocol (as described in
the man page) does work as expected regarding the fallback server.
Is there a way to use both tags and fallback with relayd(8) to mimic Apache's Failover[1]
configuration with "ProxyPass" and "BalancerMember (...) status=+H" ?
Thank you,
Joel C.
[1] https://httpd.apache.org/docs/trunk/howto/reverse_proxy.html#failover
https://man.openbsd.org/relayd.conf.5#tag