0

Not really sure whether is possible or not, but if you have a reverse proxy for HTTP/1.1 connections, would it be possible to ugprade from the reverse proxy, said connections to HTTP/2, if the destination is capable of serving HTTP/2?

If it helps, the proxy is written in go, and it makes use of the reverseproxy package.

Geo
  • 93,257
  • 117
  • 344
  • 520

1 Answers1

1

Yes it’s entirely possible.

Many web proxies (most?) are HTTP proxies (also called level 7 proxies) and have two, separate, HTTP connections - one for the incoming “frontend” and the other for the outgoing “backend”. These two connections can have completely different settings - including supporting different HTTP versions.

Other proxies are TCP proxies (also called level 4 proxies) and they have no concept of HTTP and just forward the TCP packets on and assume the otherwise will know what to do with them. In this case it is not possible To have different HTTP versions.

Saying that, most of the benefit of HTTP/2 is for the front end connection as HTTP/2 improves the performance impact of HTTP over high latency connections. Typically backend connections are over lower latency, higher bandwidth connections (maybe even in the same data centre). So while what you are asking is entirely possible whether you want to do this is more questionable. And it’s probably because of that questionable benefit that many servers don’t actually support backend connections over HTTP/2. Apache does but has it marked as experimental. Nginx does not and say they won’t. I’m not familiar with Go but looks like it might support this.

Barry Pollard
  • 40,655
  • 7
  • 76
  • 92
  • Hi Barry, if we would make abstraction of the programming language, what would be the steps needed to do such an upgrade from the proxy's side? Is there a specific header that I should include before passing the request to the upstream? I tried some experiments with setting Upgrade header but it seems that the go reverse proxy does not like it. – Geo Oct 26 '19 at 20:30
  • You wouldn’t do the upgrade. You would just tell the proxy to connect to the backend and if both sides support HTTP/2 then it would happen as part of the connection setup. You don’t upgrade a connection - you setup two independent connections. I don’t think I’m understanding your question to be honest. Maybe explaining exactly what you are trying to do (and about about why!) would help. Are you trying to effectively enable HTTP/2 support for a system that does not support it? – Barry Pollard Oct 26 '19 at 21:00
  • This is my usecse: I have many frontends, and one cloudfront distribution serving assets from an s3 bucket. I know that cloudfront supports HTTP/2, so I wanted to check how they load over HTTP/2. Basically, when a frontend requests for example image.png, depending on the frontend requesting the asset, I need to rewrite it to a specific path in the cloudfront distribution. Currently, the frontend does a request to the reverse proxy, the path gets rewritten, and then the request is sent to cloudfront. – Geo Oct 26 '19 at 21:16