简体   繁体   中英

how to use azure front door to route traffic using wildcards in path

We want to set up domain.com so to route based on path, using wildcards like this:

for most cases, domain.com/* routes to one resource, keeping original domain BUT if URL is domain.com/blog/ , it redirects to blog.domain.com/ at another resource. Basically, we want to take whatever comes after /blog/ in the first URL and append it to blog.domain.com in the second URL.

Is there a way to reliably do that using routes and rule sets in Front Door?

I tried setting up 2 routes within an endpoint:

  1. domain.com/* routes to origin group that contains our sites main static web app. Origin path is blank.
  2. domain is domain.com, patterns to match is /blog/* routes to origin group that contains custom url blog.domain.com. origin path is /*

Seems like it works sometimes, but not always. domain.com/blog does not go to blog.domain.com. Some specific paths/pages on the blog redirect properly, but others do not.

I have tried with rule sets, but haven't been able to get it to take only part of the path (everything AFTER /blog/) instead of just all or nothing.

Is there a way to reliably do that using routes and rule sets in Front Door?

Yes , we can route the specific requests that match a routing rule. I have tried to replicate the same in local; here is the routing rule engine configuration for backend pool 1 and backend pool 2.

  1. if it was wildcard *, all traffic will be route to that particular route ie main static web page.

在此处输入图像描述

  1. Create second route configuration for blog portal.在此处输入图像描述

When incoming request comes as domain.com -> its turns to first route rule and load static web app If incoming request comes as domain.com/blog/ -> it turns to second route rule and load respective backend endpoint.

reference tutorial for more information

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM