Layer7 API Management

Expand all | Collapse all

apigw 9.3 with http host header sends bad requests

  • 1.  apigw 9.3 with http host header sends bad requests

    Posted 06-25-2018 03:36 AM

    Today we upgraded our apigw from version 9.1 to 9.3. Everything works fine except that http host headers won't be sent to the backend anymore if we set them manually with the "Manage transport Properties/Headers" assertion. With version 9.1 this worked fine.

     

    Reproduce error:

     

    1) Create a new empty service

    2) Add assertion "set context variable" and enter a valid soap message for your backend service (name = myRequest, Data type = Message, content-type = text/xml; charset=utf-8)

    3) Add assertion "Manage transport Properties/Headers" (Type = HTTP Header, Operation = Add or Replace, Name = Host, value = <the host name of your backend server>

    4) Rightclick on the newly created assertion (Add Http Header) and click "Select Target Message" > Other context variable = myRequest

    5) Add assertion "Route via HTTP(S)" (URL = <your backend url, host must be given as IP, not the host name>, request source = myRequest, everything else = leave on default

     

     

    If I have this service in 9.1, my backend returns valid answer, if I have the exact same service in 9.3, my backend always returns an error 400 (Bad Request)

     

    How can we manually set host headers in the new apigw without this error?



  • 2.  Re: apigw 9.3 with http host header sends bad requests

    Posted 07-03-2018 02:23 AM

    I done a quick test on gw9.3 to route to another service (emulate the backend service, and audit the ${request.http.allheadervalues}), I can see the host header is set properly (with your steps)

     

    connection:Keep-Alive, content-length:17, content-type:text/xml; charset=utf-8, host:myhost, user-agent:Apache-HttpClient/4.2.5 (java 1.5)

     

    it could be other reason to cause  the 400 bad request. Try tcpdump the traffic.



  • 3.  Re: apigw 9.3 with http host header sends bad requests

    Posted 12-14-2018 02:29 PM

    Good afternoon,

     

    Were you able to resolve the issue? What was the final result?

     

    Sincerely,


    Stephen Hughes
    Broadcom Support



  • 4.  Re: apigw 9.3 with http host header sends bad requests

    Posted 12-17-2018 05:00 AM

    Hi,

     

    I could only solve it by disabling my manually set host header, because I found out that the apigw will send one anyway (not the one I want, though). The backend service can life with it and so do I. But if I enable my custom host header, both headers get sent and the backend will throw a "bad request" error.

     

    Regards,

    Andi



  • 5.  Re: apigw 9.3 with http host header sends bad requests

    Posted 12-18-2018 12:43 PM

    Andi,

     

    Thank you for the feedback. The HTTP Routing assertion by default does not pass through certain headers by default so the HTTP routing assertion will add in the HOST header as you have seen. The breakdown of the headers not sent through are found here: Route via HTTP(S) Assertion - CA API Gateway - 9.3 - CA Technologies Documentation  and if you need to overwrite these locked down headers

     

    Technical Note: To pass through any of the excluded headers above, add the system property com.l7tech.policy.assertion.HttpPassthroughRuleSet.headersToSkip with the list of headers to skip. For more information, see Gateway System Properties.

     

    Sincerely,

     

    Stephen Hughes

    Broadcom Support