使用Go实现HAProxy的SSL终止和HTTP/2

huangapple go评论87阅读模式
英文:

HAProxy with SSL Termination and HTTP/2 in Go

问题

我有一个用Go编写的Web应用程序,并由HAProxy进行负载均衡。HAProxy还处理SSL/TLS终止。目前,所有的响应都是HTTP/1.1,我希望它们能够是HTTP/2。我在haproxy.conf中尝试了各种方法,但无法使其工作。

我可以让一个独立的Go服务器处理自己的SSL终止并使用HTTP/2,但似乎所有当前的浏览器只支持通过TLS的HTTP/2。这是否意味着我需要在Web应用程序本身处理SSL终止?或者是否有一些我不知道的解决方法,可以继续在负载均衡器上终止SSL并使用HTTP/2?

看起来这是不可能的,但我希望有一种方法可以实现,否则我需要在每个Web应用程序上处理SSL证书,而不仅仅是在负载均衡器上处理。

英文:

I have a web application written in Go and load balanced by HAProxy. HAProxy also handles SSL/TLS termination. Currently the responses are all HTTP/1.1 and I'd like them to be HTTP/2. I've tried various things in haproxy.conf, but haven't been able to get it working.

I'm able to get a standalone Go server that handles its own SSL termination to use HTTP/2, but it looks like all current browsers only support HTTP/2 over TLS. Does this mean that I need to handle the SSL termination at the web app itself? Or is there some workaround that I don't know about so that I can continue terminating SSL at the load balancer and still use HTTP/2?

It looks like this is impossible, but I'm hoping there is a way to do it since otherwise I need to deal with SSL certificates at each web application rather than just at the load balancer.

答案1

得分: 3

如果我理解正确的话,你需要一个能够代理请求到应用程序的HTTP/2感知负载均衡器。你可以使用nginx。它可以很好地进行HTTP/2终止、负载均衡和其他许多功能。所以也许你根本不需要使用haproxy。然而,如果你想要一些高级功能,比如粘性会话,haproxy是很有用的。nginx也可以实现这些功能,但只有在商业版本中才能使用。

这里有一篇文章(在Google缓存中)介绍如何设置nginx + haproxy。

英文:

> Or is there some workaround that I don't know about so that I can continue terminating SSL at the load balancer and still use HTTP/2?

If I've got you right, you need a HTTP/2 aware load balancer which can proxy your requests to your application. You may use nginx. It can excellent do http2 termination, load balancing and many other things. So probably you may not need haproxy at all. However haproxy is useful if you want some advanced features like sticky sessions. Nginx also can do them, but only in a commercial version.

Here's an article (in Google cache) how to setup nginx + haproxy.

huangapple
  • 本文由 发表于 2017年2月16日 08:31:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/42262696.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定