URL-Based Routing For Multiple Sites under one hostname

asked 2021-11-15T18:32:45.01+00:00
Stephen Mwanzi 26 Reputation points

Hello, I would appreciate your assistance on how to go about this scenario. We currently have a Linux VM on Azure where we host our websites. All of them are under the same hostname as microsites(not subdomains). However, we now have a case where one of the websites is running on dotnet 4.7 and can't be deployed to the current VM, and needs to be a standalone app service but use the existing hostname and follow the same URL mapping structure i.e http://example.com, http://example.com/uk, http://example.com/us etc are under the same Linux VM.

If we add another path/ let's say /za, is there a way of mapping the path http://example.com/za so that it serves the content of our app service at http://example.azurewebsites.net while not affecting the existing sites and are there other alternatives? Thank you.

Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
558 questions
No comments
{count} votes

Accepted answer
  1. answered 2021-11-16T02:21:01.217+00:00
    ChaitanyaNaykodi-MSFT 9,866 Reputation points Microsoft Employee

    Hello @Stephen Mwanzi , Thank you for reaching out. If I have understood the question correctly you want to redirect an incoming request with a specific path http://example.com/za to a different backend pool (a web-app) in this scenario. I think it should be possible using URL Path Based Routing as shown in this document any request for http://contoso.com/video/* are routed to VideoServerPool, and http://contoso.com/images/* are routed to ImageServerPool. You can associate your listener to a path based request routing rule, and based on the URL path you can match the path pattern of the request and direct it to the correct backend. Please be aware that using this rule you can match the path pattern only and not to URL's query parameters. You can follow this documentation for implementation.

    Now as the backend will be a web app in this scenario. As per the documentation since app service is a multi-tenant service instead of a dedicated deployment, it uses a host header in the incoming request to resolve the request to the correct app service endpoint. Usually, the DNS name of the application, which in turn is the DNS name associated with the application gateway fronting the app service, is different from the domain name of the backend app service. Therefore, the host header in the original request received by the application gateway is not the same as the host name of the backend service. Because of this, unless the host header in the request from the application gateway to the backend is changed to the host name of the backend service, the multi-tenant backends are not able to resolve the request to the correct endpoint. Application Gateway provides a switch called Pick host name from backend target which overrides the host header in the request with the host name of the back-end when the request is routed from the Application Gateway to the backend.

    My suggestion will be test this scenario out for proof of concept before implementing it in prod environment, please let us know if you run across any issues while implementing.

    Hope this helps. Please let me know if you have any additional questions or concerns I will glad to continue with our discussion.

0 additional answers

Sort by: Most helpful