Azure Application Gateway error - 502 Bad Gateway

ramireddy ramireddy 0 Reputation points
2023-09-25T20:59:32.12+00:00

We have been trying to setup a Azure application gateway for an App service with Custom domain setup for the App Service.

Here are the steps:

  1. Setup a New Application Gateway with a Public IP
    1. Public IP has been assigned a wildcard domain from SSL.com CA ( Its been validated and it works)
      1. Also setup a A record to point to the same custom domain to call the Gateway Public IP endpoint.
  2. Setup Backend Pool, Backend Settings, Frontend IP Configuration ( wild card CA certified .pfx cert.),Listener, Rules and Health probe.
    1. Health probes comes back as healthy
  3. Setup custom domain for the App service and apply the same wild card certificate from CA ( when calling directly, the app service works). Made a public IP to test it out directly.
    1. Assign this custom domain endpoint App service as the backend pool for the Application gateway.
  4. When I verify the both the URL's both of them show the same certifying authority.
  5. Calling the App Service works as expected with no issues as well.
  6. Still getting 502 Bad gateway

Interesting this is if I change the backend Pool to point to a VM which has IIS running with the same API application hosted with the wild card cert applied, Gateway works as expected.

Not sure what I am missing from a App Service point of view and why it keep failing.

Regards,

Ramireddy

Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
{count} votes

4 answers

Sort by: Most helpful
  1. ramireddy ramireddy 0 Reputation points
    2023-09-26T15:58:50.7366667+00:00

    This was already setup as No.

    I am trying to reach the application gateway through a custom domain (xxx.mycustomdomain.com) which i have mapped in the my domain with CNAME record pointing to xxx.azurewebsites.net.

    Backend pool setting that points to App Service and this does not work. Although the app service has a custom domain setup, it always show the default URL instead when I assign it to the backend. I don't think there is a way to remove the App Service default URL that gets assigned when I create a new App service.

    User's image

    User's image

    Health probe comes back as health with this setting.

    User's image

    User's image

    0 comments No comments

  2. ramireddy ramireddy 0 Reputation points
    2023-09-26T15:59:54.1033333+00:00

    We have spent a lot of hours before reaching out. Thank you again for you help and am happy jump on call if you would like to review in person.

    0 comments No comments

  3. ramireddy ramireddy 0 Reputation points
    2023-09-27T15:00:32.2833333+00:00

    Never mind. I had to switch the backend settings to Hostname to Yes and use the hostname for it to work.

    0 comments No comments

  4. ramireddy ramireddy 0 Reputation points
    2023-09-27T15:03:10.89+00:00

    Never mind, works now. I had to switch the Backend Settings "Override with new Hostname" to yes and select "Pick hostname from backend target" for the Application gateway to work with Application gateway.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.