简体   繁体   中英

Application gateway URL path-based routing always redirect to default backend pool

I have configured 4 webapps behind Application gateway (ARM template):

  • dummyapi1.azurewebsites.de/servicehosts/dummyapi1
  • dummyapi2.azurewebsites.de/servicehosts/dummyapi2
  • dummyapi3.azurewebsites.de/servicehosts/dummyapi3
  • dummyapi4.azurewebsites.de/servicehosts/dummyapi4

web app settings

I can open web apps when I go directly to dummyapiX.azurewebsites.de/servicehosts/dummyapiX.

I want routing work this way: when I go to https://PIPofApplicationGateway/servicehosts/dummyapiX it should redirect to

dummyapiX.azurewebsites.de/servicehosts/dummyapiX

But Application Gateway always redirect to default backend pool, therefore I get 404 error.

I created Custom probes that point to:

  • /servicehosts/dummyapi1
  • /servicehosts/dummyapi2
  • /servicehosts/dummyapi3
  • /servicehosts/dummyapi4

Backend health show Healthy status for all. Backend pools point to webapps FQDN. PickHostNameFromBackendAddress for httpsSettings and PickHostNameFromBackendHttpSettings for probes are set to true. No other Path related setting are not configured in httpsSettings.

The only path-based rule is:

  • default backendpool is dummyapi4
  • "/servicehosts/dummyapi1/*" to backendpooldummy1
  • "/servicehosts/dummyapi2/*" to backendpooldummy2
  • "/servicehosts/dummyapi3/*" to backendpooldummy3

Any suggestion? What might be a root cause?

The root cause was trailing "/" in path in rules.

So instead of:

"/servicehosts/dummyapi1/*" to backendpooldummy1
"/servicehosts/dummyapi2/*" to backendpooldummy2
"/servicehosts/dummyapi3/*" to backendpooldummy3

It should be in my case

"/servicehosts/dummyapi1*" to backendpooldummy1
"/servicehosts/dummyapi2*" to backendpooldummy2
"/servicehosts/dummyapi3*" to backendpooldummy3

Now everything works

Firstly, you can confirm if you have created the virtual directory in your web app setting. Make sure the URL-based rule maps to the specific backend pool. Create the basic listener with a listening request port. Create and map a Path-based rule and bind to the listener. Get more details from this tutorial .

Then, you can type ipconfig /flushdns to clear the DNS cache In the command prompt console. Verify it again.

Ref: Error 404 : Web App Not Found – Azure Web App

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