rewrite url before landing to apigee

Hi Experts,

we have tons of proxies defined in apigee, but the client request will be prefixed. For example

/proj/customer (client request.uri)   -----rewrite at apigee to>  /customer  (apigee proxy base path)

I want to chip /proj from the URI the moment it reaches to apigee,i thought of doing it by creating a dummy proxy with a javascript like the one below and forwarding that to the same host pointing the target server to localhost by defining a localhost target server within the apigee. Essentially it's a proxy chaining, is it recommended or any other way to rewrite url at apigee? Pls, provide your approach for this and also how to forward requests to the same host without having a target server defined in hybrid.

var modifiedUri = originalUri.replace("/proj", ""); 

context.setVariable("request.uri", modifiedUri);

Define a target server with the name localhost and refer apigee dns/FQDN there.
Thanks.

Solved Solved
0 2 349
1 ACCEPTED SOLUTION

You can use Apigee to do as you describe.  It may or ma not be economical to do so, because if you chain proxies, you will run 2 API calls for every request, doubling your Apigee volume. 

Many (most?) customers use a load balancer  in front of Apigee anyway, and load balancer tools often include URL rewrite capabilities.  The Google cloud Load BAlancer (classic) includes this rewrite capability.   If that or a similar managed service is not available to you, then you can do rewrites pretty easily with nginx. Here's a tutorial on that.  Or you could use envoyproxy to do the same.  But this means you would have to manage a group of nginx or envoy servers. 

So it's up to you.  

  • use your existing managed service load balancer, if you have one, and if it supports rewrites
  • do the rewrites in Apigee, and incur the double-counting of API calls
  • do the rewrites in a self-managed cluster of nginx or envoy or similar

Any of these will work fine.

View solution in original post

2 REPLIES 2

You can use Apigee to do as you describe.  It may or ma not be economical to do so, because if you chain proxies, you will run 2 API calls for every request, doubling your Apigee volume. 

Many (most?) customers use a load balancer  in front of Apigee anyway, and load balancer tools often include URL rewrite capabilities.  The Google cloud Load BAlancer (classic) includes this rewrite capability.   If that or a similar managed service is not available to you, then you can do rewrites pretty easily with nginx. Here's a tutorial on that.  Or you could use envoyproxy to do the same.  But this means you would have to manage a group of nginx or envoy servers. 

So it's up to you.  

  • use your existing managed service load balancer, if you have one, and if it supports rewrites
  • do the rewrites in Apigee, and incur the double-counting of API calls
  • do the rewrites in a self-managed cluster of nginx or envoy or similar

Any of these will work fine.

Thanks