Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

higress 转发HTTP请求/响应时,如何保持Header大小写 #987

Open
millinchen opened this issue May 22, 2024 · 2 comments
Open

higress 转发HTTP请求/响应时,如何保持Header大小写 #987

millinchen opened this issue May 22, 2024 · 2 comments
Labels

Comments

@millinchen
Copy link

higress代理的http请求会把http header的key全转成小写?有办法不改变大小写吗?

@CH3CHO
Copy link
Collaborator

CH3CHO commented May 22, 2024

HTTP header 按规范是不区分大小写的。什么场景下需要强制约定大小写呢?

@johnlanni
Copy link
Collaborator

http header不区分大小写时符合RFC规范的,所以envoy默认转换成小写了,跟HTTP2保持一致。

如果要绕过此问题,可以开启istio api支持,然后下发这个envoyfilter:

apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: header-preserve-case
  namespace: higress-system
spec:
  configPatches:
  - applyTo: NETWORK_FILTER
    match:
      context: GATEWAY
      listener:
        filterChain:
          filter:
            name: envoy.filters.network.http_connection_manager
    patch:
      operation: MERGE
      value:
        name: envoy.filters.network.http_connection_manager
        typed_config:
          '@type': type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
          http_protocol_options:
            header_key_format:
              stateful_formatter:
                name: preserve_case
                typed_config:
                  '@type': type.googleapis.com/envoy.extensions.http.header_formatters.preserve_case.v3.PreserveCaseFormatterConfig
  - applyTo: CLUSTER
    match:
      context: GATEWAY
    patch:
      operation: MERGE
      value:
        typed_extension_protocol_options:
          envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
            '@type': type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
            explicit_http_config:
              http_protocol_options:
                header_key_format:
                  stateful_formatter:
                    name: preserve_case
                    typed_config:
                      '@type': type.googleapis.com/envoy.extensions.http.header_formatters.preserve_case.v3.PreserveCaseFormatterConfig

@johnlanni johnlanni changed the title http header 的key全变成了小写 higress 转发HTTP请求/响应时,如何保持Header大小写 May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants