Using Istio 1.34 (bundled with microk8s 1.18.2) I would like to add some custom headers to a http route. These custom headers must be injected to the http request before reaching the service:
My-Custom-Header1: “abc-123”
My-Custom-Header2: “[5, 6, 7]”
QUESTION1: Can you please show the correct way to configure the injection of the custom headers. I am confused by the istio documentation HTTPRoute. Contrary to the match field which accepts an array of HTTPMatchRequest[]. The headers field can accept only one value of type Headers. How is it possible to add more than one custome header?
QUESTION2: Notice in the VirtualService config above, there are two match under the http route. The headers field definition injects the custom headers for both match. How to restrict the custom header injection only for match.name: "main-svc-routes" ?
Thanks @Shubham.
I have read carefully the post “Add headers using virtual service” you referred before creating this post. The answer is confusing. as it is out of context of a VirtualService. I tried to use that answer in my config above. And this seems NOT to work (in Firefox Dev Tool, I don’t see the custom header added to the http request)
In that post, at the end, member “roquesao” asked practically the same question as this post. There was no answer.
This seems trivial but I am confused by itsio doc (no example and no mention of array in the headers filed) and the yaml syntax. If you know the answer, can you please fix the YAML I mentioned in the original post?
I also searched how to add 2 headers. but nothing found yet. you can ask there may be that member solved it. If i find something then i will tell you. you can also ask this on istio slack channel (for fast respone)
Asfor injecting multiple custome header, I think (but not sure) we can add them as list items. Because the documentation of Headers.HeaderOperations says that the value is map<string, string> so I think we can add each header as an map entry of a map collection.
I hope you can help to confirm. Because so far I could apply successfully the yaml but don’t see the custom header showing up in Firefox Dev Tool
Hi
i tried it. same problem vs configured but doesn’t show header (even when i applied single one). but when i add headers in response it show headers on calling. don’t know what is the issue.( have you try it with response instead of request it works.)
Its work in the response but not in request.
i tried the ingress task. in which i add the headers for both request and response.
it show headers(request) in the cookies. not in the Firefox dev tool. but the headers (response) show in the Firefox dev tool.
Hello, I am facing the same issue as Shubham has mentioned. No matter what I do but I don’t see my custom headers in the request. However, any changes in the response headers works fine (like adding or removing). Did anyone make this work? Thank you.