Share via


azure api management as reverse proxy for web apps

Question

Thursday, January 31, 2019 9:53 AM

I'm trying to setup an Azure API Management as Reverse Proxy to my web apps hosted on App Service. A few questions:

1-Is it possible to setup an API without defining any operation? My idea was to setup an inbound rule and forward the request to the backend.

2-In case an operation is required, can I define a generic URL for the operation using wildcards?

e.g: map /site/* to https://my-custom-backend-url.azurewebsites.net

Azure API Management

https://azureapimgmt.com/site1/index.html

backend

https://my-custom-backend-url.azurewebsites.net/index.html

3-Do I need to remove "/site1" from the url or it won't be forwarded?

Thiago Custodio | Software Engineer
Blog
Twitter
Meu livro de Azure

All replies (3)

Thursday, January 31, 2019 7:20 PM âś…Answered

API Management is not designed to be a simple load balancer. It has a powerful policy engine along with features necessary for providing your APIs to your customers.

That being said, you could try something similar to what I've mentioned in my previous comment along with the set-backend-service policy.

Also, if you all you require is to setup a reverse proxy for your APIs, Azure Application Gateway would be a better choice I believe.


Thursday, January 31, 2019 5:33 PM

I don't believe this is supported out of the box but should still be possible.

You would have an API with operations for each HTTP Method you need but since wildcard routes are not supported, you would have to pass the path differently, say as a query parameter.

With this, you would know

  1. backend to forward the request to - because of the API
  2. method to use
  3. path to use

And then in your policy xml, you would have to use the rewrite-uri policy.

To sum up, you would need an operation for an operation with URL like /site?p={path} and in the inbound scope of your policy xml, you would have this line

<rewrite-uri template="/site/{path}" />

So, a request to /site?p=/shop would call your backend at /site/shop


Thursday, January 31, 2019 6:59 PM

Hi PramodValavala-MSFT, thanks for your reply.

I don't know why we have this limitation. I was trying almost the same behavior but without the api management, but also with no success. Not sure to switch the target backend by url suffix on Application Gateway, is it possible?

Thiago Custodio | Software Engineer
Blog
Twitter
Meu livro de Azure