Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HAProxy with HTTP2 frontend and HTTP1.1 backend

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?

like image 880
Stephen Mahood Avatar asked Apr 23 '16 21:04

Stephen Mahood


People also ask

Does HAProxy 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.

Can HAProxy have multiple frontends?

You may add as many frontend sections as needed to expose various websites or applications to the internet.

Is HTTP2 better than HTTP1?

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.

What is frontend and backend in HAProxy?

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.


1 Answers

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.

like image 96
mikemaccana Avatar answered Oct 05 '22 14:10

mikemaccana