Download raw body.
relayd http relay: Help needed: Fallback to other rule when chosen rule fails
Hi,
I want to do something like:
table <foo> { [..ips] }
table <bar> { [..ips] }
table <fallback> { 127.0.0.1 }
http protocol "my-proto" {
[..tls]
pass request forward to <fallback>
pass request header "Host" value "foo.ca" forward to <foo>
pass request header "Host" value "bar.ca" forward to <bar>
}
relay "proxy" {
listen on egress port 443 tls
protocol "my-proto"
forward to <foo> port 8080 check tcp
forward to <bar> port 8081 check tcp
forward to <fallback> port 8086 # this is httpd
}
I've tried a lot of things, but I can't get the desired behaviour.
So I wanted to change relayd to support this.
I've found the line I need to change:
relay_http.c: line 703
if (relay_connect(con) == -1) {
relay_abort_http(con, 502, "session failed", 0);
return;
}
In this scenario, relay_connect would return -1 because of the failed
tcp check when the hosts in the table are down.
Instead of doing relay_abort_http, I would do something like:
Filter out rules with this table. If there are no more rules, abort.
If there are still rules, retry with these rules.
I'm not familiar enough with the code to backtrack like this...
But the relayd.conf manpage says this about forward to:
"This directive can be specified twice - the second entry will be
used as the backup table if all hosts in the main table are down."
I believe this holds true for redirects and relays, but not for
http relays with filters.
Could you give me some pointers to work on doing what I've described?
Also would this behaviour be ok with everyone?
Laurent
relayd http relay: Help needed: Fallback to other rule when chosen rule fails