Layer7 API Management

  • 1.  Context variable to find out the full URL for which the request has come

    Posted Sep 02, 2015 08:12 AM

    Hi,

     

    We have a network load balancer and Virtual IP under which the gateway servers are mapped. Now we need to implement one more Virtual IP for the same gateway servers on the load balancers such that, for a same service, one set of users might call the gateway using a VIP and the others might call using a different VIP. Now, we need to route the request to the end-point based on the VIP through which the request was made to the gateway.

     

    For Example: We create a VIP for internal users and ask them to call the gateway through that VIP URL --> https://abc-internal.xyz.com/<Service resolution path>

                           We create a VIP for external users and ask them to call the gateway through that VIP URL --> https://abc-external.xyz.com/<service resolution path>

     

    Both the VIPs, "abc-internal.xyz.com" and "abc-external.xyz.com" will route the request to the same gateway. Now in the back-end I have 2 different endpoints. "Endpoint-internal users" & "Endpoint - External users".

     

    Now I need to create a routing assertion as follows, which I can implement through compare variable assertion

    }

    IF request has come through URL "abc-internal.xyz.com"

      route to "Endpoint-Internal"

    Else

    route to "Endpoint-External"

    }

     

    My problem here is, I am not able to find the context variable through which I can get the values of the VIP URL for which the request was made. The context variables ${request.url.path} and ${request.http.uri} returns only the URL with the resolution path within the gateway. How do I retreive the complete URL for which the request was made (including the VIP URL)? Is there any specific context variable which will give this info?  Or is there anyother way of implementing the above mentioned scenario?

     

    Please Help!

     

    Thanks,

    Karthik



  • 2.  Re: Context variable to find out the full URL for which the request has come
    Best Answer

    Posted Sep 02, 2015 08:57 AM

    Hey Karthik,

     

    i think you are looking for ${request.url.host}

     

    here are some valuable values for future reference ( these are available by accessing the Policy Manager Help Docs )

     

    request.url.host.png

     

    Also, you may not want to hard code those URLs in your policy, but abstract that out of the the main policy if possible.



  • 3.  Re: Context variable to find out the full URL for which the request has come

    Posted Sep 02, 2015 09:25 AM

    Hey Doyle,

     

    Thanks a lot! This is exactly what I was looking for.

     

    But how do I compare the URL if I don't hard code it in the compare assertion?



  • 4.  Re: Context variable to find out the full URL for which the request has come

    Posted Sep 02, 2015 09:53 AM

    As long as the number of inbound VIP's isn't very much, you could have an XML file within a ClusterWide Property for which you would xpath at runtime ( and cache ) to get the information you need.

     

    i.e.

    /${request.url.host}/myEndpoint

     

    if this xml file grows too big though, you may want to find another place to put it.

     

    This will allow you to keep your policy environment agnostic.

     

    here is an example xml file i've used to do something very similar.

     

    routingTable.png



  • 5.  Re: Context variable to find out the full URL for which the request has come

    Posted Sep 03, 2015 10:33 AM

    Thanks!! I'm applying it