Re: relayd as a reverse-proxy in front of OpenBSD httpd + custom Golang httpd

2015-10-27 Thread Hiltjo Posthuma
On Sun, Oct 25, 2015 at 7:30 PM, Hiltjo Posthuma 
wrote:
> My /etc/relayd.conf looked something like this:
>
> table  { 127.0.0.1 }
>
> http protocol "protmyapp" {
> return error
>
> # TODO: forward non-matching traffic to standard httpd.
> match request header "Host" value "someapp.mydomain.*"
> }
>
> relay "myapp" {
> listen on 0.0.0.0 port 80
> protocol "protmyapp"
> forward to  port 8081
> }
>

I figured it out, I overlooked in relayd.conf(5) FILTER RULES:

"forward to ⟨table⟩ Forward the request to a server in the specified
table. With this option, requests can be passed to specific backend
servers. -> A corresponding forward to declaration in the RELAYS
section is required. <-".

In case someone wants to do a similar thing the working relayd.conf is
(simplified):

table  { 127.0.0.1 }
table  { 127.0.0.1 }

http protocol "protsomeapp" {
match request quick header "Host" value "someapp.mydomain.*" \
forward to 
}

relay "someapp" {
listen on 0.0.0.0 port 80
protocol "protsomeapp"

forward to  port 8080
forward to  port 8081
}

Kind regards / hope this helps someone,
Hiltjo



relayd as a reverse-proxy in front of OpenBSD httpd + custom Golang httpd

2015-10-25 Thread Hiltjo Posthuma
Hi folks!,

I have a question about how to convert my current setup with nginx +
fastcgi to OpenBSD httpd + slowcgi and relayd.

The setup is pretty simple, I have the follow subdomains:

www.mydomain.org - OpenBSD httpd, static pages.
git.mydomain.org - OpenBSD httpd, slowcgi and cgit.
someapp.mydomain.org - custom httpd application (written in Golang),
listens on a UNIX domain socket or localhost port.

I have www and git successfully working with OpenBSD httpd, cgit and
git-daemon, it works very well and was simple to setup.

Now I want to also relay someapp.mydomain.org to the local Golang
httpd, the other HTTP traffic can go to the OpenBSD httpd, this is all
running on the same server. With nginx this was possible by using
nginx "proxy_pass"[0], like:

server {
listen 80;
server_name someapp.mydomain.org;

location / {
proxy_pass
"http://unix:/domains/someapp.mydomain.org/someapp.sock:/";;
}
}

server {
listen 80;
server_name www.mydomain.org;
root /var/www/domains/www.mydomain.org/htdocs;
}

I've tried to put relayd (port 80) as a reverse-proxy in front of
httpd and relay based on the HTTP "Host" header. It seems to me from
reading the documentation
that relayd can relay to one host or table per protocol, but not relay
to different ports on the same machine, but hopefully I'm totally
wrong.

My /etc/relayd.conf looked something like this:

table  { 127.0.0.1 }

http protocol "protmyapp" {
return error

# TODO: forward non-matching traffic to standard httpd.
match request header "Host" value "someapp.mydomain.*"
}

relay "myapp" {
listen on 0.0.0.0 port 80
protocol "protmyapp"
forward to  port 8081
}

Does anyone have a similar setup and can help me with this?

Kind regards,
Hiltjo

[0] - http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass