Istio: Add a custom request header to outbound HTTP requests

Viewed 57

We want to add a custom request header to HTTP requests to a specific external endpoint. Created the following Istio configurations.

apiVersion: networking.istio.io/v1beta1
kind: ServiceEntry
metadata:
  name: httpbin-se
spec:
  exportTo:
  - .
  hosts:
  - httpbin.org
  location: MESH_EXTERNAL
  ports:
  - name: 443-port
    number: 443
    protocol: TLS
  resolution: NONE
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: httpbin-vs
spec:
  hosts:
  - httpbin.org
  http:
  - route:
    - destination:
        host: httpbin.org
      weight: 100
      headers:
        request:
          add:
            test-header: xyz

Tried testing from a container... the test-header is not getting added

bash-4.2$ curl -X GET "https://httpbin.org/headers" -H "accept: application/json"
{
  "headers": {
    "Accept": "application/json", 
    "Host": "httpbin.org", 
    "User-Agent": "curl/7.29.0", 
    "X-Amzn-Trace-Id": "Root=1-63062d1c-2d6808374e71f1ef16713fe8"
  }
}
0 Answers
Related