I'm wondering if anyone has setup HAProxy with http2 support on the frontend and HTTP/1.1 on the backend
The backend servers are currently Varnish so only support HTTP/1.1
Would http2 work in scenario were a persistent connection would be kept open to the load balancer, and the load balancer would then make the downgraded HTTP1.1 connections to the backend.
Or do both the frontend and the backend need to support HTTP2?
HAProxy Enterprise supports HTTP/2 over: unencrypted HTTP (known as h2c); encrypted HTTPS when OpenSSL 1.0. 2 or newer is available on the server.
You may add as many frontend sections as needed to expose various websites or applications to the internet.
HTTP2 is much faster and more reliable than HTTP1. HTTP1 loads a single request for every TCP connection, while HTTP2 avoids network delay by using multiplexing. HTTP is a network delay sensitive protocol in the sense that if there is less network delay, then the page loads faster.
The frontend is the node by which HAProxy listens for connections. Backend nodes are those by which HAProxy can forward requests. A third node type, the stats node, can be used to monitor the load balancer and the other two nodes.
From the HAProxy 1.8 announcement:
HAProxy 1.8 now supports HTTP/2 on the client side (in the frontend sections) and can act as a gateway between HTTP/2 clients and your HTTP/1.1 and HTTP/1.0 applications.
You'll need the h2
directive in your haproxy.conf
:
frontend myapp
bind :443 ssl crt /path/to/cert.crt alpn http/1.1,h2
mode http
More details, including HAProxy 1.8 packages, a full config file demonstrating a HTTP2 frontend and load balancing HTTP 1.1 backend are on CertSimple's load balancer with HTTP/2 and dynamic reconfig guide.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With