Haproxy: convert http1.1 request from the client to http2 on the backend side

Автор | 23.07.2024

For example, you are using this sample config

frontend myproxy
    mode  http
    bind  :8080 alpn h2,h1
    default_backend be_secure
backend be_secure
    mode http
    balance leastconn
    option http-server-close
    server dev 0.0.0.0:0 ssl verify none sni req.hdr(Host) alpn h2,h1

And get an error:

<html><body><h1>503 Service Unavailable</h1>
No server is available to handle this request.
</body></html>

It happens because your backend server uses only h2 (http2) and due to this thread https://www.mail-archive.com/haproxy@formilux.org/msg43261.html you should set the “:authority” pseudo-header

It can be done by adding ‘set-uri’ in the config

backend be_secure
    mode http
    balance leastconn
    option http-server-close
    http-request set-uri https://%[req.hdr(host)]%[pathq]
    server dev 0.0.0.0:0 ssl verify none sni req.hdr(Host) alpn h2,h1

Залишити відповідь