Override backend path not working as expected

Erik Magnusson 45 Reputation points
2023-03-01T15:40:25.22+00:00

Hello,

I have an application gateway (WAF V2) using path based routing with several app services configured in the following way:

mydomain.com -> foo.azurewebsites.net

mydomain.com/bar* -> bar.azurewebsites.net

The root route to the foo app is working as expected but I'm having trouble routing to the bar app in a satisfactory manner.

According to this: https://learn.microsoft.com/en-us/azure/application-gateway/configuration-http-settings the overridden path should be forwarded to the backend service. Therefore I expect it to work in the following way:

Request for mydomain.com/bar -> Redirected to bar.azurewebsites.net

Request for mydomain.com/bar/login -> Redirected to bar.azurewebsites.net/login

Request for mydomain.com/bar/site.css -> Redirected to bar.azurewebsites.net/site.css

What is actually happening:

Request for mydomain.com/bar -> Redirected to bar.azurewebsites.net (working correctly)

Request for mydomain.com/bar/login -> Redirected to foo.azurewebsites.net/login (which doesn't exist)

Request for mydomain.com/bar/site.css -> Redirected to foo.azurewebsites.net/site.css (which doesn't exist)

It would seem the override is not actually forwarding the path to the backend but instead overriding the path before it hits the path based rule, leading to the requests being routed to the foo app instead of to the bar app.

As of now, the only way I've been able to solve the path based routing is by creating a virtual directory in the app service set to /bar and point this to the wwwroot or publishing in a sub directory. This is less than ideal however since one cannot remove the original path /.

Is there any way to achieve what I want to accomplish using path based routing and overriding path?

Thanks.

Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
1,213 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,940 questions
{count} votes

Accepted answer
  1. KapilAnanth-MSFT 49,536 Reputation points Microsoft Employee Moderator
    2023-03-08T09:29:45.81+00:00

    @Erik Magnusson

    Welcome to the Microsoft Q&A Platform. Thank you for reaching out & I hope you are doing well.

    I understand that you would like to use Path-Based Routing to route traffic across two app service domains.

    Your requirement is that,

    • Request for mydomain.com/bar -> Redirected to bar.azurewebsites.net
    • Request for mydomain.com/bar/login -> Redirected to bar.azurewebsites.net/login
    • Request for mydomain.com/bar/site.css -> Redirected to bar.azurewebsites.net/site.css

    The combination of Path-based route and override backend path value as "/" should redirect mydomain.com/bar to bar.azurewebsites.net*

    The issue is that "subsequent" requests, while using a Path based Rule does not work and are going to "foo.azurewebsites.net"

    I tried to repo this in my lab using JAVA WebApps, however, I am not able to repo the issue.

    Later, you confirmed this is because of "~" sign in links, which in ASP.NET refers to the web root and also informed you were able to resolve this.

    Since the virtual path is "/", this is assumed to be the root, even if we publish in a sub directory like "/bar". The app will only recognize "/bar" as the root if you create an extra virtual path under that name. This, however, means that you will need two virtual paths in the same app and one of them, the "/" path, will point nowhere (since it can't be removed or changed).

    Kindly let us know if the below helps or you need further assistance on this issue.

    Thanks,

    Kapil


    Please don’t forget to close the thread by clicking "Accept the answer" wherever the information provided helps you, as this can be beneficial to other community members.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.