istio send custom dynamic header to application by either using uuid or refer value from another already exiting header

huangapple go评论59阅读模式
英文:

istio send custom dynamic header to application by either using uuid or refer value from another already exiting header

问题

在Istio中,是否有一种方法可以设置自定义请求头(x-custom-header),其值是动态值(uuid),或者可以从已经存在的头部设置自定义头的值?

我正在使用网关 + 虚拟服务 + Envoy(sidecar)。

在nginx中的示例配置选项为:
proxy_set_header x-custom-header $connection:$connection_requests;

我在我的虚拟服务中尝试了下面的代码片段,但将字面值 "{{ uuid }}" 转发到了我的应用程序。

http:
  - headers:
      request:
        set:
          x-custom-header: '{{ uuid() }}'
       
    match:
    - uri:
        prefix: /
英文:

Is there way in istio to set a custom request header (x-custom-header) with value as dynamic value (uuid) or setting value of the custom header from an already existing header?

I am using gateway + virtualservice + envoy(sidecar)

Example configuration options in nginx =
proxy_set_header x-custom-header $connection:$connection_requests;

I tried below snippet in my virtual service and got literal value "{{ uuid }}" forwarded to my application.

` http:

  • headers:
    request:
    set:
    x-custom-header: '{{ uuid() }}'

    match:

    • uri:
      prefix: /`

答案1

得分: 1

我能够通过在虚拟服务中使用以下代码片段来解决这个问题:

- headers:
    request:
      set:
        x-custom-header: '%REQ(x-request-id)%'
英文:

I was able to solve this by using following snippet in virtual service

   http:
  - headers:
      request:
        set:
          x-custom-header: '%REQ(x-request-id)%'

huangapple
  • 本文由 发表于 2023年6月26日 20:59:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76556933.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定