Based on Header, need to route client url to a proxy version with same name but different backend points.

Not applicable

I have a use case where the internal version of a proxy has changed but the client URL remains the same .So now in apigee edge i have two proxies with same Name but different Back end Points .Can i use a header to make the client url land on specific proxy .

To give you more info,in the back-end i have now two java files now and @path annotation is different (as mentioned as different backend points)

Please suggest a way to achieve the same.

0 9 2,666
9 REPLIES 9

@Arpit Sharma

I'm trying to understand why do we need to have 2 proxies, we can have single proxies with 2 target endpoint. Internally we can check some header/variable value(provided by consumer) and accordingly redirect it to appropriate endpoint. Let me know your thought on this.

@Arpit Sharma

I'm trying to understand why do we need to have 2 proxies, we can have single proxies with 2 target endpoint. Internally we can check some header/variable value(provided by consumer) and accordingly redirect it to appropriate endpoint. Let me know your thought on this.

Not applicable

Hi Arpit ,

You cannot use a parameter to make the request land on a specific proxy.Proxies are identified by base path .You can have two proxies with same name but different base path (best practice is to have different names for each proxy).If the use case is to select two different back ends based on header parameter then you can do that in a javascript policy to over write the "target.url" parameter based on your condition.

@naveen

@Sunandita Dam

Consider this as a case where the proxy has a minor version upgrade and not a major version upgrade . The client end url will remain the same ,though i have two proxies with different backend points . The reason for creating a second proxy in minor upgrade is for creating different swagger UI for two proxies.

Conditional targets should solve this problem if I understand you correctly. Read the section on conditional targets in the documentation here http://docs.apigee.com/api-services/content/understanding-routes. There is an example included for routing based on header.

Conditional targets

The <RouteRule> tag lets you direct a request to a target based on a condition. You can use flow variables, query parameters, HTTP headers, message content, or contextual information such time of day and locale to determine the target endpoint. For example, you might include a geographical area, such as US and UK, in a request URL. You can then route a request to a target endpoint based on the region.

@Arpit Sharma

Let me summarize your question

1) You have two api proxy with same basepath

2) These two proxies have different backend URL

3) The CLient URL i.e. the consumer trying to access the proxy should be same for both the URL.

If all the above three point are correct and then the solution to this is use one VHOST for one proxy and diferent VHOST for other proxy.

One DOMANIN name can point to more than one VHOST.

But in the VHOST , give different ports. i.e. one vhost provide say 1243 port and other vhost provide 1244 port. Rest all configuration for vhost can be same.

I hope you got this.

@gbhandari

We cannot deploy 2 proxies with the same base path in the same environment right?

@Amar.Nekkanti

We can deploy two proxies with the same base path name provided

1) VHOST name are different both the proxies (default.xml file)

In your case, you also want to provide the same base path name or url to client.

So in this case, you need to create one extra VHOST that points to same Common Name (Host alias name) but it has different port number.

please let me know if you have any doubts.

@Arpit Sharma

Case1

If you have the proxies with different base path and you want to give the same URL to the client and if you want to route to the proxies based on the header value, then we can create another proxy with the base URL you want provide it to the client and create 2 targets. 1st target server should point to the 1st proxy and 2nd target server should point to the 2nd proxy.

Have 2 route rules and have condition for them in such a way that they should to hit the target based on the header values.

Example for route tules:

<RouteRule name="routeRuleName1"> <Condition>(request.header.headerValue = "1st")</Condition> <TargetEndpoint>!st_Target_Name</TargetEndpoint> </RouteRule>

<RouteRule name="routeRuleName2"> <Condition>(request.header.headerValue = "2nd")</Condition> <TargetEndpoint>!st_Target_Name</TargetEndpoint> </RouteRule>

Case2

If you have single proxy with 2 targets and you want to hit the targets based on the header values then just have the above 2 route rules

I hope this helps