envoyproxy/envoy

grpc-web: add per route config

Open

#11 089 ouverte le 6 mai 2020

Voir sur GitHub
 (10 commentaires) (2 réactions) (0 assignés)C++ (5 373 forks)batch import
area/grpchelp wanted

Métriques du dépôt

Stars
 (27 997 stars)
Métriques de merge PR
 (Merge moyen 8j) (378 PRs mergées en 30 j)

Description

Hi guys,

I've been recently building a system that users gRPC-web and HTTP as communication protocols.

Something like:

static_resources:
  listeners:
    - name: listener_0
      address:
        socket_address: 
          address: 0.0.0.0
          port_value: 80
      filter_chains:
        - filters:
          - name: envoy.filters.network.http_connection_manager
            config:
              codec_type: auto
              stat_prefix: ingress_http
              route_config:
                name: my_grpc_service_route
                virtual_hosts:
                  - name: my_grpc_service
                    domains:
                      - "mygrpcservice.example.com"
                    routes:
                      - match:
                          prefix: "/MyGrpcService"
                        route:
                          cluster: my_grpc_service
                          max_grpc_timeout: 0s
                    cors:
                      allow_origin_string_match:
                        - prefix: "*"
                      allow_methods: GET, PUT, DELETE, POST, OPTIONS
                      allow_headers: keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout
                      max_age: "1728000"
                      expose_headers: grpc-status,grpc-message
                  - name: my_http_service
                    domains:
                      - "myhttpservice.example.com"
                    routes:
                      - match:
                          prefix: "/"
                        route:
                          cluster: my_http_service
                    cors:
                      allow_origin_string_match:
                        - prefix: "*"
                      allow_methods: GET, PUT, DELETE, POST, OPTIONS
                      allow_headers: keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent
                      max_age: "1728000"
              http_filters:
                - name: envoy.filters.http.grpc_web
                - name: envoy.filters.http.cors
                - name: envoy.filters.http.router

I always found weird that the envoy.filters.http.grpc_web is applied to both virtual hosts and to all the routes in them and I should just rely on the envoy.filters.http.grpc_web to skip non-gRPC-web routes so they fallback to plain HTTP.

Now I'm implementing some file uploads to a service behind Envoy and getting 413 Payload Too Large. Based on #2919, it seems like the envoy.filters.http.grpc_web filter is buffering the file upload causing the issue.

Maybe I'm just missing something fundamental since I'm pretty new to Envoy, but my question is: how can I avoid such behaviour? How can I have the grp_web filter applied only to the gRPC route? Is really my only option to use 2 listeners (and 2 different ports)?

Thanks in advance!

Guide contributeur