How to implement nginx.ingress.kubernetes.io/proxy-body-size NginX annonation in Istio?

2/26/2020

I am migrating a productive Nginx ingress controller to Istio Ingress Gateway and I need to migrate the following annonation:

nginx.ingress.kubernetes.io/proxy-body-size

The question is, how I can I set up the proxy body size in Istio for requests from outside the service mesh?

I have tried something like the following, but it doesn't seem to have effect:

apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: hello-istio-request-body-size
  namespace: hello-istio
spec:
  workloadSelector:
    labels:
      run: hello-istio
  configPatches:
    # The first patch adds the lua filter to the listener/http connection manager
  - applyTo: HTTP_FILTER
    match:
      context: SIDECAR_INBOUND
      listener:
        portNumber: 13451
        filterChain:
          filter:
            name: "envoy.http_connection_manager"
            subFilter:
              name: "envoy.router"
    patch:
      operation: INSERT_BEFORE
      value: # lua filter specification
       name: envoy.lua
       config:
         inlineCode: |
           function envoy_on_request(request_handle)
             local bufferReq = request_handle:body()
             request_handle:logWarn("after body()")
             request_handle:logWarn(bufferReq:length())
             request_handle:headers():add("request-body-size", tostring(bufferReq:length()))
           end

Can you help me?

Thank you in advance.

Best regards, rforberger

-- Ronny Forberger
istio
kubernetes
nginx-ingress

0 Answers