envoyproxy / envoyproxy/gateway
Allow request buffering for HTTP while excluding WebSocket upgrades
- Dominant language
- Go
- Stars
- 3k
- Forks
- 864
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 140
Description
*Description*:
I recently started working with Envoy and found that request buffering is not compatible with WebSockets. This is documented by Envoy [here](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/http/upgrades#http-upgrades)):
> Buffering is generally not compatible with upgrades, so if the [Buffer filter](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) is configured in the default HTTP filter chain it should probably be excluded for upgrades by using [upgrade filters](https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto#envoy-v3-api-field-extensions-filters-network-http-connection-manager-v3-httpconnectionmanager-upgradeconfig-filters) and not including the buffer filter in that list.
I want to enable request buffering at the gateway level (a default behavior | same listener for normal HTTP requests and WebSocket traffic on different paths), but since it doesn't work with WebSockets, I need to disable buffering for specific HTTP routes.
Even though custom filter chains can only be configured on a per-HttpConnectionManager basis, I tried to create a BackendTrafficPolicy (with `requestBuffer.limit=<...>`) attaching it to the Gateway, and another one (with `mergeType=JSONMerge,requestBuffer.limit={}` trying to remove the buffering config) attaching it to the HTTPRoute, but got this error (which is expected):
```
invalid BufferPerRoute.Buffer: embedded message failed validation | caused by: invalid Buffer.MaxRequestBytes: value must be greater than 0
invalid BufferPerRoute.Buffer: embedded message failed validation | caused by: invalid Buffer.MaxRequestBytes: value must be greater than 0
invalid BufferPerRoute.Buffer: embedded message failed validation | caused by: invalid Buffer.MaxRequestBytes: value must be greater than 0
```
So, the only option I see is to create a BackendTrafficPolicy (with `mergeType=StrategicMerge` to "override" only specific fields, since it'll be merged with the one applied at the Gateway level) for each HTTPRoute that I want to enable request buffering. I also want to avoid using `EnvoyPatchPolicy` in production.
All that said, is there a plan to support a different filter chain (basically the same as the default HTTP filter chain, but removing the Buffer filter) for WebSockets when request buffering is enabled?
Not sure if I'm missing something here. If so, please let me know.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.