Target Server

Hi

I am looking for conditional basis selection of the server name, Can I have the server picked dynamically, where in abcdef is the server name which will be built in previous policy's.

<LoadBalancer>

<Server name={abcdef}/>

</LoadBalancer>

0 6 351
6 REPLIES 6

Hi @siva,

A better approach would be to use route rules with conditions and target endpoints. Define your target endpoints first, then use the route rules to dynamically determine which target to call.

Here's an example:

<RouteRule name="MyRoute">
  <Condition>request.header.routeTo = "TargetEndpoint1"</Condition>
  <TargetEndpoint>TargetEndpoint1</TargetEndpoint>
</RouteRule>
<RouteRule name="default">
 <TargetEndpoint>TargetEndpoint2</TargetEndpoint>
</RouteRule>

Read more here:

https://docs.apigee.com/api-platform/fundamentals/understanding-routes#determiningtheurlofthetargete...

@Robert Johnson Thank you for quick reply. We have a requirement to redirect to target servers basing on the locale(en_us,gb_GB)/environment in this case I have to maintain different TargetEndpoints per locale and env. So i was looking for a solution of handling using one TargetEndpoint and dynamic server name.

Not applicable

Any success on this requierement @siva ? I have a requirement similar to this, need to change the host for the final request when I need to redirec to a mock server instead of the real back end services. So something like this would address my issue as well. Thanks!

Hi @siva,

Try to use javascript to set the target url in Target-endpoint flow . In this case the target server connections should be load balancer url ( the load balancer will take care of balancing the load on respective locale) .

Thanks,

Latheef D

Hi @Raul Nunez I used RouteRule approach.

I also want an answer to this same question. I am using route rules for some other thing.