是否可以使用HAproxy代理传入的h2c请求?
我已经尝试了以下配置using this tutorial
frontend receiver
mode http
bind *:80
bind *:443 ssl crt-list /some/file alpn h2,h2c,http/1.1
default_backend processor此配置适用于h2 (HTTP/2安全)请求,并将HTTP/1.1请求发送到后端。但是,它不适用于通过curl发出的h2c (HTTP/2明文)请求。我得到以下错误消息:
$ curl --http2-prior-knowledge http://server.com/status
...
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle ...)
> GET /status HTTP/2
...
* http2 error: Remote peer returned unexpected data while we expected SETTINGS frame. Perhaps, peer does not support HTTP/2 properly.
...
curl: (16) Error in the HTTP2 framing layer我怀疑这是因为HAProxy在响应中需要h2数据(而不是h2c)。为了支持传入的h2c请求,我需要更改HAProxy配置中的哪些内容?有什么建议吗?
发布于 2019-02-21 13:07:40
根据HAproxy通道中的discussion,可以使用bind上的proto h2设置代理h2c请求。但是,目前无法在同一端口上同时侦听HTTP/1.1和HTTP/2请求。
在HAProxy上运行h2c的示例配置:
frontend f_h2c
mode http
option http-use-htx
bind *:8080 proto h2
default_backend local_node
backend local_node
mode http
option http-use-htx
server localhost localhost:9090 proto h2发布于 2019-02-01 07:24:47
如果您的后端服务器支持h2c,则可以在tcp模式下代理传入的请求。这就是您使用的教程对h2请求所做的工作,但它没有理由不适用于h2c。
因为该教程是用HAProxy has added HTTP/2 support in v1.8编写的,所以它还可以在http模式下代理h2请求,但据我所知,它不可能在h2c上这样做。文档没有明确说明这一点,但说明ALPN用于协商HTTP/2和this question状态,没有添加h2c支持。
HAProxy 1.9 did add h2c support in the backend,但仍然没有注意到前端支持它。
老实说,前端的h2c支持通常是有限的,因为浏览器不支持它,因为它需要升级步骤或服务器支持它的假设(这两个都不是理想的),不像h2,它可以作为TLS协商的一部分进行协商,而不需要额外的往返或假设。
有没有什么特别的原因让你想要在前端支持h2c,因为可能有更好的方法来实现你想要的。
https://stackoverflow.com/questions/54470016
复制相似问题