Using OpenBSD Relayd(8) as an Application Layer Gateway
tumfatig.net
tumfatig.net
https://man.openbsd.org/man8/relayd.8
https://man.openbsd.org/man8/relayctl.8
https://man.openbsd.org/man5/relayd.conf.5
Side note, I haven't heard failover used in the context of kicking unhealthy backends before. Failover is typically something that would be implemented with carp(4) (aka VRRP, but with support for active/active setups) on two different machines running relayd.
https://man.openbsd.org/man4/carp.4
Nothing beats the sheer elegance of OpenBSD for networking tasks. :-)
In OpenBSD “Failover” also appears in “Trunking a Wireless Adapter”:
https://www.openbsd.org/faq/faq6.html#Wireless
“The trunk is set up in failover mode, so either interface can be used. If both are available, it will prefer the bge0 port, since that is the first one added to the trunk device.“
[1]: https://www.tiltedwindmillpress.com/product/httpd-and-relayd...
Really looking forward to the 3rd edition of Absolute OpenBSD.
So it's heart is a reverse http proxy. generalized to be a generic application layer proxy. and then integrated with the pf firewall to be a ip layer forwarder. note the distinction in the manual between redirections(ip forwarder) and relays(application proxy)
According to the manual it has application specific relays for http and dns. for other than that you have to use the generic tcp relay. if you are redirecting, it does not look at the internals of the packet at all.
https://man.openbsd.org/httpd#HISTORY
> The httpd program first appeared in OpenBSD 5.6. httpd is based on relayd(8).
The original author of relayd also made a Rust prototype: https://github.com/reyk/relayd-rs
One thing to note about relayd is that it only resolves names (DNS) at startup. Meaning if the name of a host changes you will need to reload relayd.
I suspect the vast majority of OpenBSD users never hit a "scaling wall". What do you mean by product?
In a previous life I installed two OpenBSD routers with a 10GbE card each. With carp(4) they could push nearly 20Gbps total. This was back in 2015 or so.
"Scaling" would just be matter of adding more nodes, or replace with 40GbE cards (which would require a more powerful CPU).
Perhaps running a high traffic relayd on them would have reduced the throughput. But that smells like poor architecture: let routers be routers and load balancers be load balancers :)
prefork number
When using relays, run the specified number of processes to handle relayed
connections. This increases the performance and prevents delays when connecting
to a relay. relayd(8) runs 3 relay processes by default and every process
will handle all configured relays.
The source[1] seems to be quite clear; relayd(8)[2] describes the main notions ("entities": relay, protocol, etc.) involved in the configuration/source.[0]: https://man.openbsd.org/relayd.conf.5
[1]: http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.sbin/relayd...
an ssh -D SOCKS5 tunnel requires you to present credentials on the jump host. This daemon bypasses that need. (happy to be corrected. I'd love to be wrong)
What I love about openBSD documentation is that if it's not there in the docs, one can be sure that it doesn't exist.
It was just about time, considering there was a jestful tricking the developer of relayd to reprogram it to httpd. IIRC he got epic tricked into it! In the sense he didn't even know he was making a webserver until he actually made it. This may not be a very true version, but I love to believe so.
The camaraderie and passion in the project is mind boggling.
Update: I think strictly speaking auth is outside the scope of relayd, but looking at the docs, I bet I could wire something together around having specific cookies or other headers.
match request type cookie "ident" value "hashed password"
or match request header "Authorization" value "Basic dXNlcm5hbWU6dGhpcyBpcyBzZWNyZXQK"
The above will not work by the way, last time I used relayd I found it to be one of the few openbsd programs where I had a hard time thinking the same way as it's author. That is, The syntax made my head hurt. I got it working but it was a chore. I think it is more that it ends up being a very complicated domain than poor syntax.From relayd.conf manpage:
"TLS client and server
When combining both modes, TLS server and client, relayd(8) can filter TLS connections as a man-in-the-middle. This combined mode is also called "TLS inspection". The configuration requires additional X.509 certificate settings; see the ca key description in the PROTOCOLS section for more details."
Check if it's possible to disable sending SNI.