2

The scenario is exactly the same on this post. But I need an nginx solution. I am not introducing haproxy or any additional service on top of it.

Charles
  • 1,008
  • 10
  • 21

1 Answers1

2

Nginx does not support back end connections in HTTP/2 and have no intention of bringing this in (for more details see my answer to this question).

So you’re only option is to introduce haproxy or some other TCP proxy rather than a HTTP proxy, some additional service or switch from Nginx to Apache (which does support HTTP/2 back end connections with mod_proxy_http2).

Why do you feel you need HTTP/2 on the back end? As detailed in same answer linked above, most of the HTTP/2 benefits are from having HTTP/2 in the front end. The only real reason I can think to have it on the back end is to support end to end HTTP/2 Server Push but that is really complex to do over multiple HTTP/2 connections and is best left to the last hope to initiate (see here for discussion of this for Apache which is also relevant for other web servers like nginx).

Barry Pollard
  • 40,655
  • 7
  • 76
  • 92
  • The linked answer is debatable. I know of systems that greatly benefit from using HTTP/2 from front ends to back ends, for the same reasons there are great benefits of using HTTP/2 from browsers to front ends: multiplexing, reduced number of connections, HTTP/2 push, better use of TCP features, less resource usage, etc. It's a shame that Nginx does not want to support HTTP/2 towards the back end. – sbordet Feb 01 '18 at 20:40
  • I’d be interested in hearing more about that. Got a link with any details? Push is the main reason I see for now for end to end connections as mentioned but 1) also not supported by Nginx and 2) perhaps not ready for mainstream yet anyway (excellent article on way here: https://jakearchibald.com/2017/h2-push-tougher-than-i-thought/). – Barry Pollard Feb 01 '18 at 20:50
  • NGINX has supported HTTP/2 Server Push since version 1.13.9. I'm trying to accomplish the same thing as the OP, but with the same results. Reverse proxy gets lost when it attempts an http 1.1 connection, but the listener is expecting an http2 client connection. The answer is http2-prior-knowledge, but I'm not certain how to send that via reverse proxy. – Michael Aug 08 '19 at 01:14
  • Updated the answer since Push has since been introduced to nginx. However the main point that nginx does not support HTTP/2 at the backend remains the same. You cannot currently do what you want with nginx so either need to switch to something that does support this it enable HTTP/1.1 as well on the backend. – Barry Pollard Aug 08 '19 at 06:47