How to get HTTP/2 working in a Kubernetes cluster using ingress-nginx

5/9/2019

We have a number of services behind an API gateway which is itself behind ingress-nginx. We're trying to use HTTP/2 to speed up data transfer to the front-end but all of our connections are still being done with HTTP/1.1.

The connection from client to nginx is over HTTPS, but nginx communicates with our API gateway using HTTP, and the gateway also uses HTTP to communicate with the backend services.

Do we need to use HTTPS from end-to-end to get HTTP/2 to work? If so, what's the best way to set this up re: using certificates? If not, what could be causing the connection to drop to HTTP/1.1?

We are using ingress-nginx version 0.21.0, which has nginx 1.15.6 and OpenSSL 1.1.1, which should be sufficient to support TLS 1.3/ALPN/HTTP2. Our nginx-configuration configmap has use-http2 set to true and I can see that the pod's /etc/nginx.conf has a listen ... http2; line.


Edit 10/05/2019:

Further to the comments of @Barry Pollard and @Rico, I've found out that AWS Elastic Load Balancer, which sits in front of our ingress-nginx controller, doesn't support HTTP/2. I've cut nginx out of the stack and our API Gateway is being provisioned its own Network Load Balancer. However, we're still on HTTP/1.1. It looks like ASP.Net Core 2.2's HTTP server Kestrel uses HTTP/2 by default, so I'm not sure why the connection is still dropping to 1.1.

-- Chris Swinchatt
amazon-web-services
asp.net-core
http2
kubernetes
ssl

1 Answer

5/9/2019

Like @BarryPollard said you shouldn't need HTTP/2 end to end to establish HTTP/2 connections on your browser.

It sounds like whatever you are using for a client is dropping to HTTP/1.1, make sure you try with one of the following:

  • Chrome 51
  • Firefox 53
  • Edge 12
  • Internet Explorer 11
  • Opera 38

You didn't specify what architecture is fronting your nginx. Is it connected directly to the internet? or it's going through cloud load balancer? CDN? You can also test with Wireshark as described here.

-- Rico
Source: StackOverflow