Please enable Javascript to view the contents

 ·  ☕ 3 分钟

HTTP Protocol Options

https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/upstreams/http/v3/http_protocol_options.proto#extensions-upstreams-http-v3-httpprotocoloptions-autohttpconfig

This extension may be referenced by the qualified name envoy.upstreams.http.http_protocol_options

extensions.upstreams.http.v3.HttpProtocolOptions

HttpProtocolOptions specifies Http upstream protocol options. This object is used in typed_extension_protocol_options, keyed by the name envoy.extensions.upstreams.http.v3.HttpProtocolOptions.

This controls what protocol(s) should be used for upstream and how said protocol(s) are configured.

This replaces the prior pattern of explicit protocol configuration directly in the cluster. So a configuration like this, explicitly configuring the use of HTTP/2 upstream:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
clusters:
  - name: some_service
    connect_timeout: 5s
    upstream_http_protocol_options:
      auto_sni: true
    common_http_protocol_options:
      idle_timeout: 1s
    http2_protocol_options:
      max_concurrent_streams: 100
     .... [further cluster config]

Would now look like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
clusters:
  - name: some_service
    connect_timeout: 5s
    typed_extension_protocol_options:
      envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
        "@type": type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
        upstream_http_protocol_options:
          auto_sni: true
        common_http_protocol_options:
          idle_timeout: 1s
        explicit_http_config:
          http2_protocol_options:
            max_concurrent_streams: 100
     .... [further cluster config]

Schema:

1
2
3
4
5
6
7
{
  "common_http_protocol_options": "{...}",
  "upstream_http_protocol_options": "{...}",
  "explicit_http_config": "{...}",
  "use_downstream_protocol_config": "{...}",
  "auto_config": "{...}"
}
  • common_http_protocol_options

    (config.core.v3.HttpProtocolOptions) This contains options common across HTTP/1 and HTTP/2

  • upstream_http_protocol_options

    (config.core.v3.UpstreamHttpProtocolOptions) This contains common protocol options which are only applied upstream.

  • explicit_http_config

    (extensions.upstreams.http.v3.HttpProtocolOptions.ExplicitHttpConfig) To explicitly configure either HTTP/1 or HTTP/2 (but not both!) use explicit_http_config. If the explicit_http_config is empty, HTTP/1.1 is used.

    This controls the actual protocol to be used upstream.

    Precisely one of explicit_http_config, use_downstream_protocol_config, auto_config must be set.

    1
    2
    3
    4
    5
    
    {
    "http_protocol_options": "{...}",
    "http2_protocol_options": "{...}",
    "http3_protocol_options": "{...}"
    }
    
  • use_downstream_protocol_config

    (extensions.upstreams.http.v3.HttpProtocolOptions.UseDownstreamHttpConfig) This allows switching on protocol based on what protocol the downstream connection used.

    This controls the actual protocol to be used upstream.

    Precisely one of explicit_http_config, use_downstream_protocol_config, auto_config must be set.

  • auto_config

    (extensions.upstreams.http.v3.HttpProtocolOptions.AutoHttpConfig) This allows switching on protocol based on ALPN

    This controls the actual protocol to be used upstream.

    Precisely one of explicit_http_config, use_downstream_protocol_config, auto_config must be set.

ALPN Protocol is negotiated

extensions.upstreams.http.v3.HttpProtocolOptions.AutoHttpConfig

https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/upstreams/http/v3/http_protocol_options.proto#extensions-upstreams-http-v3-httpprotocoloptions-autohttpconfig

[extensions.upstreams.http.v3.HttpProtocolOptions.AutoHttpConfig proto]

If this is used, the cluster can use either HTTP/1 or HTTP/2, and will use whichever protocol is negotiated by ALPN with the upstream. Clusters configured with AutoHttpConfig will use the highest available protocol; HTTP/2 if supported, otherwise HTTP/1. If the upstream does not support ALPN, AutoHttpConfig will fail over to HTTP/1. This can only be used with transport sockets which support ALPN. Using a transport socket which does not support ALPN will result in configuration failure. The transport layer may be configured with custom ALPN, but the default ALPN for the cluster (or if custom ALPN fails) will be “h2,http/1.1”.

1
2
3
4
5
6
{
  "http_protocol_options": "{...}",
  "http2_protocol_options": "{...}",
  "http3_protocol_options": "{...}",
  "alternate_protocols_cache_options": "{...}"
}
  • http_protocol_options

    (config.core.v3.Http1ProtocolOptions)

  • http2_protocol_options

    (config.core.v3.Http2ProtocolOptions)

分享

Mark Zhu
作者
Mark Zhu
An old developer