We have a proxy with a policy step of Assigned "Host" header and we added a AssignMessage like this
<Add> <Headers> <Header name="Host">*host-url-here*</Header> </Headers> </Add>
But somehow the "Host" header does not get passed on to the target service (deployed on kubernetes). Looks like the Message Processor strips off the header. Any steps/documentation to resolve this?
Solved! Go to Solution.
Dear @Anvi,
Whatever value you set in AssignMessage will be captured in “message” variables, which will be passed to MP but some reserved values, including “host”, may not be forwarded to end target.
More details on the different types of variables (target, message, response, etc..) are described at Apigee Doc - Variables reference
If you want to pass a host value to your end target, you can use a small JS script to assign value in "target.header.host". Follow the instruction in this post (2015 and relevant).
Download the sample bundle shared in that post to see how it is implemented.
Hi @Anvi, did you check the Trace session?
Try using Set tag of AssignMessage Policy instead of Add.
<Set> <Headers> <Header name="Host">*host-url-here*</Header> </Headers> </Set>
That doesn't seem to work either.
In the above example you can see that the header is being set though the request to the target service it's missing it.
I'm attaching the example proxy header-example-echo-rev1-2018-08-06.zip
We also tried with this solution though that's from 2015 and it doesn't seem to work anymore.
Dear @Anvi,
Whatever value you set in AssignMessage will be captured in “message” variables, which will be passed to MP but some reserved values, including “host”, may not be forwarded to end target.
More details on the different types of variables (target, message, response, etc..) are described at Apigee Doc - Variables reference
If you want to pass a host value to your end target, you can use a small JS script to assign value in "target.header.host". Follow the instruction in this post (2015 and relevant).
Download the sample bundle shared in that post to see how it is implemented.
Curl request UI doesnot display some of the values in header, so you may not see "Host" there.
A better way to verify is to use http://mocktarget.apigee.net/echo which simply echoes back whatever values being passed in.
Attached is my trace result. My end target is http://mocktarget.apigee.net/echo .
You may want to put debug log on your own target to view exactly what "host" being sent to your target.
Thanks @Brendan!
I was using the same echo endpoint but after looking at your screenshot I found that I was setting the header in the preflow of the proxy endpoint instead of the preflow of the target endpoint, that make it work.
Cool. If this helps, please upvote the solution so others can benefit.
Thanks @Matias.
User | Count |
---|---|
3 | |
2 | |
1 | |
1 | |
1 |