我尝试解决这个用例:
- 浏览器客户端通过 HTTP/2 连接到 Kong API 网关。
- Kong 将 HTTP/2 连接代理到后端微服务并保持打开状态。
- 用例结果应该是,客户端通过 HTTP/2 与微服务连接。
看起来,Kong 接受来自客户端的 HTTP/2 调用,而不是通过普通 HTTP 调用微服务。
这种情况有什么解决办法吗?我知道 Kong 应该能够在 gRPC 案例中与上游保持联系。
在 docker compose 中设置:
#In docker-compose.yml
....
# I call running container at localhost:9081 with http2
KONG_PROXY_LISTEN: 0.0.0.0:9081 http2, 0.0.0.0:9082 http2 ssl
在kong配置文件中设置(使用DBless)
#In Kong.yml
services:
- name: target-service
host: target-api-test #docker container name
port: 9000
routes:
- name: target-api-route
paths:
- /microservice-api
最佳答案
我认为这主要是因为 nginx 不支持指定的上游服务器的 HTTP/2 here .
Q: Will you support HTTP/2 on the upstream side as well, or only support HTTP/2 on the client side?
A: At the moment, we only support HTTP/2 on the client side. You can’t configure HTTP/2 with proxy_pass.
关于http2 - Kong - 通过 HTTP/2 连接到上游,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62300821/