Preventing original host name from gateway to backend target

Alpee Jain 96 Reputation points
2023-05-04T10:57:57.5566667+00:00

HI All,

I've set a DNS for my application gateway and in my http settings I 've set "Override with new host name" as No, when i access the url with application gateway's DNS, browser automatically navigates to the app service default .azurewebsites.net url. How do i prevent this?

Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
1,069 questions
{count} votes

1 answer

Sort by: Most helpful
  1. KapilAnanth-MSFT 45,451 Reputation points Microsoft Employee
    2023-05-17T04:38:58.53+00:00

    @Alpee Jain

    Welcome to the Microsoft Q&A Platform. Thank you for reaching out & I hope you are doing well.

    I believe you have went though Preserve the original HTTP host name between a reverse proxy and its back-end web application and Configure App Service with Application Gateway as you have mentioned you had disabled "Override with new host name".

    You should not preserve the hostname, instead, you should replace it with the backend app service's hostname - Only then will app service accept the requests.

    If you preserve,

    appgw.contoso.com ---------> App Gw --------> appgw.contso.com ------> AppService | This is wrong

    If you overwrite,

    User's image

    which is correct.

    To have different domains is not a recommended approach.

    • I would suggest you to see if you could use the same domain in AppGw and in App Services.
    • One of the notable problems with having different domains is, absolute path links will fail.
    • Only relative paths would work.
    • Best example for this would be
    • App services default 80--->443 Redirection.
    • Client ---> http://appgw.contoso.com ----> AppGw ----> http://contoso.azurewebsites.net
    • AppService sends a 301 and redirects to https://contoso.azurewebsites.net
    • To avoid the above, we can disable HTTPS redirection in AppService.
      • Make sure HTTP is supported
      • WebApp --> Configuration -->General Settings --> HTTPS only as OFF
      • User's image
      • Validate this by accessing the HTTP version of the appservice

    You confirmed that the issue has been resolved post this.

    For the path based rules,

    • I would recommend you to check the logs of the backend pool (2nd One) and see if the traffic hit this or not?
    • Also, you can use the Access logs and see to which backend pool the traffic http(s)://<gatewayurl>/api is flowing
    • Whether the first pool or the expected backend pool.
      • User's image

    Kindly let us know if this helps or you need further assistance on this issue.

    Thanks,

    Kapil


    Please don’t forget to close the thread by clicking "Accept the answer" wherever the information provided helps you, as this can be beneficial to other community members.

    0 comments No comments

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.