使用 h2c 代理请求到后端

Proxy requests to backend using h2c

在这里重新提问the question from HA-Proxy discourse site,希望得到更多关注。

我正在使用 HA-Proxy 版本 1.9.4 2019/02/06 将 HTTP 流量代理到 h2c 后端。然而,我看到 HA-Proxy 在代理请求时将 :scheme 设置为 https(据我所知,在请求中使用 SSL)。当我直接访问后端时,:scheme 设置为 http 并且请求是预期的非 SSL。我已经使用 wireshark 验证了这个 HA-Proxy 行为。

关于我应该在我的配置中更改什么的任何建议,以便我可以设置以确保在将请求代理到后端时将 :scheme 设置为 http

我正在使用 curl 7.54.0 发出请求: $卷曲http://localhost:9090 其中 HA-Proxy 正在侦听端口 9090。

我的 HA-Proxy 配置文件:

global
   maxconn 4096
   daemon

defaults
   log   global
   option http-use-htx
   timeout connect 60s
   timeout client 60s
   timeout server 60s

frontend waiter
    mode http
    bind *:9090
    default_backend local_node

backend local_node
    mode http
    server localhost localhost:8080 proto h2

暂不支持。 client=>haproxy连接可以HTTP/2,haproxy=>server连接不可以

https://cbonte.github.io/haproxy-dconv/1.9/configuration.html#1.1

HTTP/2 is only supported for incoming connections, not on connections going to servers.

只需在服务器定义中添加 proto h2

引用自example

server server1 192.168.1.13:80 proto h2

这是haproxy-1.9的实验性功能,您必须启用option http-use-htx才能使用它。

option http-use-htx 自 haproxy-2.0-dev3.

以来默认启用

这被报告为 issue in haproxy github and has been fixed in version 2.0