"502 Bad Gateway"

Jessie 85 Reputation points
2023-07-04T07:17:04.3833333+00:00

Hello Everyone

I am having troubles with solving an issue with DNS name translation.

I think the issue stems from DNS not translating properly because I have checked the network settings and it seems fine to me.

Browser Error Message:

"502 Bad Gateway"

Microsoft-Azure-Application-Gateway/v2

Environment:

1.Domain name was purchased via App Service Domain.

2.TLS certificates are from a well-known CA.

(TLS certifcates were imported into the server, exported as .pfx files and upload to the application gateway)

3.Public and Private DNS already configured (with child DNS Zone).

  1. Records have been created.
  2. Backend server: windows server.

Network Environment:

  1. Hub and Spoke network environment Application gateway, firewall and DNS (public and private) resides in the hub network.
  2. Network architecture: Client PC→Application Gateway→Azure Firewall→Backend server.
  3. FW rules allow https port traffic to the backend target subnet.
  4. Routes to and from both networks have been created.
  5. Private DNS already linked to the backend target network.
  6. Application gateway backend probe not configured.

Findings:

NSG test: OK

Network connection test: Fails with "Socket could not be opened to run the connectivity check" on the backend target.

Backend Health: Unhealthy (Received invalid status code: 502 in the backend server’s HTTP response. As per the health probe configuration, 200-399 is the acceptable status code. Either modify probe configuration or resolve backend issues.)

Any help would be appreciated.

Azure DNS
Azure DNS
An Azure service that enables hosting Domain Name System (DNS) domains in Azure.
714 questions
Azure Virtual Network
Azure Virtual Network
An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.
2,590 questions
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,106 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,151 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jessie 85 Reputation points
    2023-07-10T00:03:00.1166667+00:00

    @KapilAnanth-MSFT

    Thank you for all the suggestions.

    I reached out to support the same day I posted here, and they got back to me.

    The problem was because DNS was not properly translating as I had suspected.

    All I needed to do was link the Private DNS to the application gateway virtual network and restarted the application gateway.

    That solved the problem and now the backend health status has changed to "healthy".


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.