Azure Front Door URL Rewrite rules not working as planned

David Echo 126 Reputation points
2021-05-20T13:40:03.433+00:00

I have set up Azure Front Door. There are several App Services set up as such:

https://www.thisismydomain2021.com/appservice1 --> https://this-is-my-app-service-1.azurewebsites.net
https://www.thisismydomain2021.com/appservice2 --> https://this-is-my-app-service-2.azurewebsites.net

The matching is using the "/appservice1/", "/appservice2/".

I do not want those matching paths to make it through to the App Services. For Example:

https://www.thisismydomain2021.com/appservice1/this/folder/makeitso.html --> https://this-is-my-app-service-1.azurewebsites.net/this/folder/makeitso.html

I did try pretty much everything to remove "appservice1" and appservice2" from the origin URL using a rule set.

Condition: Request Path Contains "/appservice1/" Case transform To Lower
Action: URL Rewrite Source Pattern: "/appservice1/" Destination: "/" Preserve unmatched path: Yes

The only one that I managed to see do any action in the logs was this:
Condition: Request Path Contains "/appservice1/" Case transform To Lower
Action: URL Rewrite Source Pattern: "/" Destination: "/testaddition/" Preserve unmatched path: Yes

And the result is shown below. Not what I wanted, but it proved that it is possible to rewrite the URL in some way, just not how I want it.:
https://this-is-my-app-service-1.azurewebsites.net/appservice1/testaddiition/this/folder/makeitso.html

Any help greatly appreciated.
Thank you
David

Azure Front Door
Azure Front Door
An Azure service that provides a cloud content delivery network with threat protection.
668 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. PenguinBulletin Jarren 5 Reputation points
    2024-08-24T05:34:33.19+00:00

    You need to modify the Route configurations to match the below:

    • Patterns to match: /appservice1/* and /appservice2/*
    • Origin path: /
    • Rulesets: None

    For reference, check https://video2.skills-academy.com/en-gb/azure/frontdoor/front-door-url-rewrite?pivots=front-door-standard-premium#source-pattern under the Source Pattern heading. It's honestly easily missable and took me ages to figure out myself.

    Essentially, the Ruleset's Source Pattern only occur after the Patterns to match path. So it would never rewrite it as doesn't account for the whole URL.

    The approach would be to instead have your Route sending you to your Origin's / path. By default, leaving it empty carries the requested path forward to the appservice.

    Best to test it by hooking up your Frontdoor's Diagnostic settings (you want Access Log most of all) to a Log Analytics Workspace, which you can tie to an Application Insights. This will show you the final https://this-is-my-app-service-1.azurewebsites.net URLs and how they interact with Frontdoor and the rulesets.

    1 person found this answer helpful.

  2. Sruthi Saranya Karthikeyan 231 Reputation points Microsoft Employee
    2021-06-01T10:00:06.373+00:00

    Hello @David Echo ,

    Have you tried configuring the specific match path as /appservice1/* and the custom forwarding path as '/' in the routing rule?

    I think this should help with the specific configuration that you wish to have. You can refer to the following page for examples: https://video2.skills-academy.com/en-gb/azure/frontdoor/front-door-url-rewrite

    Do feel free to reach out in case of any additional questions or concerns or if the above suggestion doesn't work.

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.


  3. Paweł Żółtaniecki 1 Reputation point
    2022-10-20T16:39:47.87+00:00

    But how we can use rewrite in proper way. It is not working at all


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.