azure-web-app-serviceazure-application-gateway

Azure app gateway redirection does not rewrite the default azure url to custom domain name


My website is hosted through azure app service and it is given a custom domain name as well.

Let's say (actual names are hidden) my default azure app service url is https://myazureexamplesite.azurewebsites.net and the custom domain I have is https://custdomain.org

So in the azure app gateway, I have correctly configured the backend pool (azure app service), listener which listens to my custom domain and added the rule to say that this listener will be direct to the configured backend pool. Also the custom domain is directed to the app gateway's ip.

Unexpected Scenario:

So when someone hit the url https://custdomain.org it is directed to https://myazureexamplesite.azurewebsites.net

Action wise it is correct but I don't need to see the url as default app service url.

What I want is that the same app service content should be shown in the https://custdomain.org url.

Also for security purpose I don't want to direct custom domain directly to app service ip which eventually gives me the result I want.

I am not sure why this type of behavior is happening with azure app gateway. I have previously tried with azure frontdoor and it worked perfectly. For some budgeting reasons I am unable to use that in here. I have to go through the same app gateway. I am not sure whether this is the expected behavior for azure app gateway or not.

It would be a great if someone can help me to understand this scenario.

Thank you


Solution

  • when someone hit the url https://custdomain.org it is directed to https://myazureexamplesite.azurewebsites.netIf you want same app service content should be shown in the https://custdomain.org url check this below workaround

    Updated backend pool with app service create custom health probe to configure correct custom domain name as its host name like below:

    enter image description here

    In the backend setting select -> Https -> User well-known CA certificate as YES -> "Override with new hostname" to "No" -> select custom health probe like below:

    enter image description here

    In listener -> add listener with HTTPS protocol with PFX certificates like below:

    enter image description here

    In rule type add https listener choose Backend Pool of App Service and select HTTP settings of App Gateway to connect the App Service backend like below:

    enter image description here

    Now, when testing the backend health and web application using the custom domain are in healthy state it redirects with domain successfully like below:

    enter image description here

    Reference:

    Redirection to App Service URL - Azure Application Gateway | Microsoft Learn