I have two web servers running on my machine. One is listening on port 8080 and the other on 8081.
$ curl http://localhost:8080
I am the API
$ curl http://localhost:8081
<html> <head><title>Flat file</title></head>
<body><h1>I am the flat flile</h1></body> </body> </html>
I want to setup a relay that forwards traffic to one or the other based on the request path of an HTTP request. Here is my /etc/relayd.conf...
$ cat /etc/relayd.conf
api_host="127.0.0.1"
api_port="8080"
table <apihosts> {$api_host}
flat_host="127.0.0.1"
flat_ports="8081"
table <flathosts> {$flat_host}
log state changes
log connection
http protocol "chatty" {
pass request path "/api/*" forward to <apihosts>
pass request path "/*" forward to <flathosts>
}
relay "forum.cwal.net" {
listen on 0.0.0.0 port 80
protocol "chatty"
forward to <apihosts> port $api_port
forward to <flathosts> port $flat_ports
}
However, it seems like all requests are going to the server on port 8081.
$ curl http://localhost
<html>
<head><title>Flat file</title></head>
<body><h1>I am the flat flile</h1></body>
</body>
$ curl http://localhost/api
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>404 Not Found</title>
<style type="text/css"><!--
body { background-color: white; color: black; font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', sans-serif; }
hr { border: 0; border-bottom: 1px dashed; }
--></style>
</head>
<body>
<h1>404 Not Found</h1>
<hr>
<address>OpenBSD httpd</address>
</body>
</html>
On that last request, I expect to see the "I am the API" request but I'm not.
relayd
, but: What do you get withcurl http://localhost/api/
andcurl http://localhost:8080/api/
?