higress icon indicating copy to clipboard operation
higress copied to clipboard

给指定域名的转发设置为 http1 的 codec

Open whitebear009 opened this issue 2 months ago • 1 comments

If you are reporting any crash or any potential security issue, do not open an issue in this repo. Please report the issue via ASRC(Alibaba Security Response Center) where the issue will be triaged appropriately.

  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

Ⅰ. Issue Description

有一个长连接的业务场景,因为服务只支持 http1,而浏览器优先通过 http2 访问 higress gateway,higress gateway 如果用 auto codec 会用 http2 与服务交互,从而会有一些问题,所以想给对应域名的转发设置为 http 1。

我研究了一下 EnovyFilter 的配置,配置了如下的 yaml 貌似没有作用:

apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: http1-codec
  namespace: higress-system
spec:
  configPatches:
    - applyTo: HTTP_FILTER
      match:
        context: GATEWAY
        listener:
          filterChain:
            filter:
              name: envoy.filters.network.http_connection_manager
        original_destination:
          host: "sit-sse.xxx.com"
      patch:
        operation: REPLACE
        value:
          name: envoy.filters.http.router
          typed_config:
            "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
            http_connection_manager:
              codec_type: HTTP1

Ⅱ. Describe what happened

If there is an exception, please attach the exception trace:

对应 access log:

{"authority":"sit-sse.xxx.com","bytes_received":"415","bytes_sent":"2806","downstream_local_address":"172.28.225.141:443","downstream_remote_address":"10.1.9.64:13276","duration":"1133","istio_policy_status":"-","method":"POST","path":"/api/agentchat/conversation","protocol":"HTTP/2","request_id":"ce281ac8-f05e-4780-b8be-0ebd745b476c","requested_server_name":"sit-sse.xxx.com","response_code":"200","response_flags":"-","route_name":"ingress-service/ingress-sit-sse-xxx-com","start_time":"2024-12-02T06:12:49.351Z","trace_id":"dcba9f5a35c2c336ec05ba12e3d75d19","upstream_cluster":"outbound|80||web-be-mdw-dev-site-sitxxxsse-80.ingress-service.svc.cluster.local","upstream_host":"10.212.92.233:80","upstream_local_address":"172.28.225.141:52546","upstream_service_time":"-","upstream_transport_failure_reason":"-","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36","x_forwarded_for":"10.1.9.64"}

仍然是 HTTP2.0

Ⅲ. Describe what you expected to happen

Ⅳ. How to reproduce it (as minimally and precisely as possible)

Ⅴ. Anything else we need to know?

Ⅵ. Environment:

  • Higress version: 1.4.2
  • OS :
  • Others:

whitebear009 avatar Dec 02 '24 06:12 whitebear009