multiple connection managers

693 views
Skip to first unread message

Nikos Skalis

unread,
Apr 30, 2021, 12:22:45 PM4/30/21
to envoy-users
Hi,

I would like to configure two envoy.filters.network.http_connection_manager, one for plain http1, one for http1 websocket connections.
The underlying reason is that I use the envoy.filters.http.buffer http filter in case of plain http1 requests, which doesn't work in case of websockets (due to the http upgrade as the official docs explain).

So, I came up with

              -
                name: envoy.filters.network.http_connection_manager
                typed_config:
                  stat_prefix: ingress_http1
                  codec_type: HTTP1
_remote_address
                  xff_num_trusted_hops: 0
                  common_http_protocol_options:
                    idle_timeout: 900s
                  route_config:
                    name: route_http1
                    virtual_hosts:
...
                  http_filters:
                    -
                      name: envoy.filters.http.buffer  # Note that buffering is generally not compatible with upgrades, so if the Buffer filter is configured in the default HTTP filter chain it should probably be excluded for upgrades by using upgrade filters and not including the buffer filter in that list.
                      typed_config:
                        "@type": type.googleapis.com/envoy.extensions.filters.http.buffer.v3.Buffer
                        max_request_bytes: 5242880
                    -
                      name: envoy.filters.http.router
                      typed_config: 
                        "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
...
              -
                name: envoy.filters.network.http_connection_manager
                typed_config:
                  stat_prefix: ingress_http1_websocket
                  codec_type: HTTP1
                  xff_num_trusted_hops: 0
                  common_http_protocol_options:
                    idle_timeout: 900s

                  upgrade_configs:
                    -
                      upgrade_type: websocket
                  route_config:
                    name: route_http1_websocket
                    virtual_hosts:
...
                  http_filters:
                    -
                      name: envoy.filters.http.router
                      typed_config: 
                        "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
...

which is wrong, as it complains about:

[2021-04-30 18:04:31.097][23561][critical][main] [external/envoy/source/server/config_validation/server.cc:60] error initializing configuration '/etc/envoy.d/envoy.mesh.yaml': Error: terminal filter named envoy.filters.network.http_connection_manager of type envoy.filters.network.http_connection_manager must be the last filter in a network filter chain.


Can a more experienced envoy user (than me) enlighten please what I am doing wrong?

I am not able to understand the underlying issue and error message.


with kind regards,

Nikos Skalis

unread,
May 3, 2021, 6:09:47 AM5/3/21
to envoy-users
I think the answer relies in utilising the "buffer per route" feature described here: https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/http/buffer/v3/buffer.proto#envoy-v3-api-msg-extensions-filters-http-buffer-v3-buffer

                      -
                        name: resp_api_junos_{{ x.host_name }}
                        domains:
                          - "{{ x.host_name }}.junos.ip-spotlight.xxx.xxx"
                        routes:
                          -
                            match:
                              prefix: "/"
                              headers:
                                -
                                  name: :method
                                  exact_match: GET
                            route:
                              weighted_clusters: 
                                clusters:
                                  - 
                                    name: cluster_api_junos_{{ x.host_name }}
                                    weight: 100
                                runtime_key_prefix: weighted

                  http_filters:
                    -
                      name: envoy.filters.http.buffer  # Note that buffering is generally not compatible with upgrades, so if the Buffer filter is configured in the default HTTP filter chain it should probably be excluded for upgrades by using upgrade filters and not including the buffer filter in that list.
                      typed_config:
                        "@type": type.googleapis.com/envoy.extensions.filters.http.buffer.v3.Buffer
                        max_request_bytes: 5242880


Can someone advise how to "buffer per route" feature can be utilised to reconfigure the above part based on it?

Nikos Skalis

unread,
May 3, 2021, 7:51:33 AM5/3/21
to envoy-users
fixed with:

                      -
                        name: resp_api_junos_{{ x.host_name }}
                        domains:
                          - "{{ x.host_name }}.junos.ip-spotlight.xxx.xxx"
                        routes:
                          -
                            match:
                              prefix: "/"
                              headers:
                                -
                                  name: :method
                                  exact_match: GET
                            route:
                              weighted_clusters: 
                                clusters:
                                  - 
                                    name: cluster_api_junos_{{ x.host_name }}
                                    weight: 100
                                runtime_key_prefix: weighted
                        typed_per_filter_config:
                          envoy.filters.http.buffer:  # Note that buffering is generally not compatible with upgrades, so if the Buffer filter is configured in the default HTTP filter chain it should probably be excluded for upgrades by using upgrade filters and not including the buffer filter in that list.
                            "@type": type.googleapis.com/envoy.extensions.filters.http.buffer.v3.BufferPerRoute
                            buffer:
                              max_request_bytes: 5242880

Reply all
Reply to author
Forward
0 new messages