I am trying to send a request header in my Inbound request, but this header gets overriden by Apigee and always points to the specified virtualhost hostname.
I tried setting the following property in target endpoint propert
Host
But this doesnt seem to solve my problem.
Can someone please help me out to resolve this issue?
@sreeharsha.r Are you trying this on the cloud or on-premise ? If you are on-premise then you might want to modify couple of properties on the message-processorās http.properties:
HTTP.retain.headers=Host
possible values are useFirst, useLast, allowDuplicates, multiValued
if value is empty, then all options useFirst, useLast, allowDuplicates, multiValued are false
Where are you overriding the host header? It sounds like your overriding it on the client side (inbound request)? Or are you trying to modify it within the proxy flow? If the latter, which flow? If the former, can you clarify? When I try to do that it wonāt hit my test proxy.
I have to send a header named āHostā from my Client application to a Backend server. When i send it from the client, the request that i receive on my backend has the Host header but it is overridden by the OPDK server Host details. I want to retain this header value that is sent from the client.
sreeharsha.r , do you have a load balancer in front of the routers ? probably its dropping the header that you are sending and adding the host header required by the Virtualhost to hit the routers .
Nothing wrong with the proxy. I tried the same proxy and set the host header in the response using a javascript policy (using your proxy) and it works fine when I bypass the ELB. When I make requests via the ELB, I can see the host header being sent by the MP but its getting chopped by the ELB. When I bypass the ELB and make the api request directly against the routers, I get the host header back. So itās the load balancer which is removing the host header.
Ok let me make it clear, I am trying to pass a host header in the request. I tried two scenarios to achieve this.
Passed the header from the client
Set the request header using JS policy
But in both cases the request i receive on my backend has a different host header (which is the host name of the router). Is there no-ways i can send a host header other then the router host? Why is apigee server overriding this value?
Is there some configuration i need to do to enforce this?
Ok. The javascript policy in your proxy was setting response.header.host so I was confused. If you use the attached proxy you would be able to send the custom host header using the javascript policy:
This means the host header is being sent to the backend. But please note that apigee routers use the host header to classify the request, so even if you send a host header from the client side which is not the virtualhostās hostalias, then the request would fail with a 404. Setting the host header in the javascript or assign message policy is still an option.forward-test-sap-rev1-2015-05-12-1.zip
Yes, this is exactly what i assumed. I saw the Host header being set in the trace session. But when i get this request in the backend server the host header always contains the origin host details and not the one seen in trace session.
If i do a curl for the same backend passing host header i get the header as is, this is what we expect using a API Proxy as well. It should not override the header value.
You could manually override the Host header value for the target by setting the variable ātarget.header.hostā. This should be done in the target request flow.
Setup an AssignMessage or JavaScript policy that assigns the value of request.header.host to target.header.host.