Hello @Nitya V ,
Welcome to Microsoft Q&A Platform. Thank you for reaching out & hope you are doing well.
I understand that you would like to configure Azure Application gateway path-based routing to 2 app services in the backend without using a custom domain.
You can find the step-by-step configuration of Application gateway with App service using default domain in the below document:
Now, coming to your requirement which is as below:
- appgateway-public-ip/d1/something -> api1-app-service
- appgateway-public-ip/d2/different -> api2-app-service
For backend pool configuration:
You need to create 2 backend pools : one containing the api1-app-service and other containing the api2-app-service.
For Listener configuration:
Then you can create a basic listener with the required port (you don't need to use multi-site listener as you will be using the default domain of the App service instead of a custom domain).
For the backend settings:
- When creating a backend setting, give it a name
- Select HTTP/HTTPS as the desired backend protocol using port 80/443
- If using HTTPS/port 443, select "Yes" for "Backend server’s certificate is issued by a well-known CA".
- Make sure to set "Override with new host name" to "Yes"
- Under "Host name override", select "Pick host name from backend target". This setting will cause the request towards App Service to use the "azurewebsites.net" host name, as is configured in the Backend Pool.
For Rule configuration:
- Under "Rules", click to add a new "Request routing rule"
- Provide the rule with a name
- Select an HTTP or HTTPS listener that is not bound yet to an existing routing rule
- Under "Backend targets", choose a default Backend Pool in which App Service has been configured
- Configure the HTTP settings with which Application Gateway should connect to the App Service backend
- Under Path-based routing:
- For Path, type /d1/*.
- For Target name, type a name.
- For HTTP setting, select your HTTP setting
- For Backend target, select the api1-app-service.
- Select Add to save the path rule and return to the Add a routing rule tab.
- Repeat to add another rule for api2-app-service.
- Select Add to add the routing rule and return to the Configuration tab.
- Select "Add" to save this configuration
NOTE: The default backend target mentioned at the top of the rule handles the request for the default domain (/*
) without any paths and the backend targets mentioned under the path-based routing handles the requests for the specific paths configured.
By default, App Service starts your app from the root directory of your app code. But certain web frameworks don't start in the root directory. For example, Laravel starts in the
public
subdirectory. Such an app would be accessible athttp://contoso.com/public
, for example, but you typically want to directhttp://contoso.com
to thepublic
directory instead. If your app's startup file is in a different folder, or if your repository has more than one application, you can edit or add virtual applications and directories.
Points to remember:
This configuration comes with limitations. We recommend reviewing the implications of using different host names between the client and Application Gateway and between Application and App Service in the backend. For more information, please review the article in Architecture Center:
Preserve the original HTTP host name between a reverse proxy and its back-end web application
When App Service doesn't have a custom domain associated with it, the host header on the incoming request on the web application will need to be set to the default domain, suffixed with "
.azurewebsites.net
" or else the platform won't be able to properly route the request. The host header in the original request received by the Application Gateway will be different from the host name of the backend App Service.
https://learn.microsoft.com/en-us/azure/application-gateway/url-route-overview
https://learn.microsoft.com/en-us/azure/application-gateway/create-url-route-portal
Kindly let us know if the above helps or you need further assistance on this issue.
Please "Accept the answer" if the information helped you. This will help us and others in the community as well.