-
Notifications
You must be signed in to change notification settings - Fork 742
Enable envoy grpc-web filter for HTTP2 listener #886
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ import ( | |
| accesslog "github.com/envoyproxy/go-control-plane/envoy/config/accesslog/v3" | ||
| core "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" | ||
| listener "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3" | ||
| grpc_web "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/grpc_web/v3" | ||
| router "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/router/v3" | ||
| tls_inspector "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/listener/tls_inspector/v3" | ||
| hcm "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3" | ||
|
|
@@ -92,15 +93,30 @@ func addXdsHTTPFilterChain(xdsListener *listener.Listener, irListener *ir.HTTPLi | |
| }}, | ||
| } | ||
|
|
||
| // Allow websocket upgrades for HTTP 1.1 | ||
| // Reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism | ||
| if !irListener.IsHTTP2 { | ||
| if irListener.IsHTTP2 { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. from the godoc on this is a little misleading i think? since the codec type is always set to "auto" and will infer the downstream protocol which could be HTTP/1 and upgraded when talking with the backend to gRPC now that this filter is applied There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How should I configure it so that it can touch it ? @sunjayBhatia
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good point @sunjayBhatia, we could limit
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated the PR with the codec type change from auto to http2
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems useful for clients to be able to use gRPC-Web over HTTP/1 -> Envoy -> gRPC backend over HTTP/2 as well! but seems like that could be a separate feature if desired |
||
| // Set codec to HTTP2 | ||
| mgr.CodecType = hcm.HttpConnectionManager_HTTP2 | ||
|
|
||
| // Enable grpc-web filter for HTTP2 | ||
| grpcWebAny, err := anypb.New(&grpc_web.GrpcWeb{}) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| grpcWebFilter := &hcm.HttpFilter{ | ||
| Name: wellknown.GRPCWeb, | ||
| ConfigType: &hcm.HttpFilter_TypedConfig{TypedConfig: grpcWebAny}, | ||
| } | ||
| // Ensure router is the last filter | ||
| mgr.HttpFilters = append([]*hcm.HttpFilter{grpcWebFilter}, mgr.HttpFilters...) | ||
| } else { | ||
| // Allow websocket upgrades for HTTP 1.1 | ||
| // Reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism | ||
| mgr.UpgradeConfigs = []*hcm.HttpConnectionManager_UpgradeConfig{ | ||
| { | ||
| UpgradeType: "websocket", | ||
| }, | ||
| } | ||
|
|
||
| } | ||
|
|
||
| // TODO: Make this a generic interface for all API Gateway features. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.