Hi,

I have noticed that relayd(8) sends a "Connection: close" HTTP header even if the backend server has sent a "Connection: keep-alive" HTTP header.

Here's my configuration:
# cat /etc/httpd.conf
server "default" {
        listen on * port 80
        location * {
                root "/htdocs/hugo"
        }
}

# cat /etc/relayd.conf
ext_addr="127.0.0.1"
table <fallback> { 127.0.0.1 }
http protocol https {
        match request header append "X-Forwarded-For" value "$REMOTE_ADDR"
        match request header append "X-Forwarded-By" \
            value "$SERVER_ADDR:$SERVER_PORT"
        tcp { sack, backlog 128 }
}
relay wwwtls {
        listen on $ext_addr port 81
        protocol https

        forward to <fallback> port http
}

If I used curl(1) to get resources from httpd(8), it uses only one HTTP connection:
# curl -Ivs http://localhost:80/ http://localhost:80/css/all.min.css
*   Trying 127.0.0.1:80...
* Connected to localhost (127.0.0.1) port 80 (#0)
HEAD / HTTP/1.1
Host: localhost
User-Agent: curl/7.79.0
Accept: */*

* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Connection: keep-alive
Connection: keep-alive
< Content-Length: 7729
Content-Length: 7729
< Content-Type: text/html
Content-Type: text/html
< Date: Sat, 13 Nov 2021 00:20:07 GMT
Date: Sat, 13 Nov 2021 00:20:07 GMT
< Last-Modified: Wed, 27 Oct 2021 07:27:51 GMT
Last-Modified: Wed, 27 Oct 2021 07:27:51 GMT
< Server: OpenBSD httpd
Server: OpenBSD httpd

<
* Connection #0 to host localhost left intact
* Found bundle for host localhost: 0xcdeb98aae80 [serially]
* Can not multiplex, even if we wanted to!
* Re-using existing connection! (#0) with host localhost
* Connected to localhost (127.0.0.1) port 80 (#0)
HEAD /css/all.min.css HTTP/1.1
Host: localhost
User-Agent: curl/7.79.0
Accept: */*

* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Connection: keep-alive
Connection: keep-alive
< Content-Length: 59344
Content-Length: 59344
< Content-Type: text/css
Content-Type: text/css
< Date: Sat, 13 Nov 2021 00:20:07 GMT
Date: Sat, 13 Nov 2021 00:20:07 GMT
< Last-Modified: Wed, 24 Mar 2021 22:34:18 GMT
Last-Modified: Wed, 24 Mar 2021 22:34:18 GMT
< Server: OpenBSD httpd
Server: OpenBSD httpd

<
* Connection #0 to host localhost left intact

But if I use curl(1) to get the same resources via relayd(8), the connections are closed for each resources:
# curl -Ivs http://localhost:81/ http://localhost:81/css/all.min.css
*   Trying 127.0.0.1:81...
* Connected to localhost (127.0.0.1) port 81 (#0)
HEAD / HTTP/1.1
Host: localhost:81
User-Agent: curl/7.79.0
Accept: */*

* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Connection: keep-alive
Connection: keep-alive
< Connection: close
Connection: close
< Content-Length: 7729
Content-Length: 7729
< Content-Type: text/html
Content-Type: text/html
< Date: Sat, 13 Nov 2021 00:22:24 GMT
Date: Sat, 13 Nov 2021 00:22:24 GMT
< Last-Modified: Wed, 27 Oct 2021 07:27:51 GMT
Last-Modified: Wed, 27 Oct 2021 07:27:51 GMT
< Server: OpenBSD httpd
Server: OpenBSD httpd

<
* Closing connection 0
* Hostname localhost was found in DNS cache
*   Trying 127.0.0.1:81...
* Connected to localhost (127.0.0.1) port 81 (#1)
HEAD /css/all.min.css HTTP/1.1
Host: localhost:81
User-Agent: curl/7.79.0
Accept: */*

* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Connection: keep-alive
Connection: keep-alive
< Connection: close
Connection: close
< Content-Length: 59344
Content-Length: 59344
< Content-Type: text/css
Content-Type: text/css
< Date: Sat, 13 Nov 2021 00:22:24 GMT
Date: Sat, 13 Nov 2021 00:22:24 GMT
< Last-Modified: Wed, 24 Mar 2021 22:34:18 GMT
Last-Modified: Wed, 24 Mar 2021 22:34:18 GMT
< Server: OpenBSD httpd
Server: OpenBSD httpd

<
* Closing connection 1

If I use telnet(1) and send the HTTP commands "by hand", I could see that the HTTP connection was left up and that I could grab several resources ; so the connection is not really closed by relayd(8).

Is there a way to tell relayd(8) to not send that extra "Connection: close" header?

Thank you,
Joel C.

Reply via email to