1

I am trying to set up a front proxy in envoy where I pass the path in a header (test-header in below example).

    - filters:
      - name: envoy.filters.network.http_connection_manager
        typed_config:
          "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
          codec_type: AUTO
          stat_prefix: ingress_http
          route_config:
            name: local_route
            virtual_hosts:
            - name: backend
              domains:
              - "*"
              routes:
              - match:
                  prefix: "/service/1"
                request_headers_to_add:
                - header:
                   key: "test-path"
                   value: request.path
                route:
                  cluster: service1
              - match:
                  prefix: "/service/2"
                route:
                  cluster: service2
          http_filters:
          - name: envoy.filters.http.router
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router

I see there is a request.path attribute in envoy https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/advanced/attributes

How can I pass this value to yaml config?

Shawon0418
  • 181
  • 1
  • 3
  • 12

1 Answers1

0

From the docs, the attributes are:

only exposed to CEL runtime in RBAC filter, as well as Wasm extensions via get_property ABI method.

So in your case, you can't really use them directly.

To get the path in your test-path header, you can instead use HTTP command operators in your custom request/response headers:

routes:
- match:
    prefix: "/service/1"
  request_headers_to_add:
  - header:
      key: "test-path"
      value: "%REQ(:path)%"

This has been tested with Envoy 1.27.0.

norbjd
  • 10,166
  • 4
  • 45
  • 80