An Azure Application Gateway named AppGW1 returns 502 - Web server received an invalid response for every request. AppGW1 is deployed in subnet AppGwSubnet (10.0.1.0/24). Its backend pool contains two VMs in subnet BackendSubnet (10.0.2.0/24) in the same virtual network. Each backend VM accepts HTTP requests on its private IP address and returns HTTP 200 in under one second when the request uses the Host header 127.0.0.1. You collect the configuration shown in the exhibit.
| Item | Configuration |
|---|---|
| Backend pool | 2 VMs: 10.0.2.4, 10.0.2.5 |
| BackendHttpSetting | HTTP, port 80, default health probe |
| Default site on backend VMs | Listening on each VM's private IP on port 80; accepts Host header 127.0.0.1 |
| NSG on BackendSubnet | Allows inbound TCP 80 from 10.0.1.0/24 |
| NSG on AppGwSubnet | No rules that block outbound TCP 80 |
| Route table on AppGwSubnet | 10.0.2.0/24, next hop type Virtual appliance, next hop 10.0.9.4 |
| Virtual appliance at 10.0.9.4 | Drops TCP 80 traffic destined for BackendSubnet |
| VNet DNS servers | Azure-provided |
What is the most likely cause of the 502 errors?
Application Gateway can return 502 errors when failed health probes leave no healthy backend servers. Here, the backend sites respond correctly and the NSGs permit the required traffic. However, the UDR sends probes through an appliance that drops TCP 80 traffic. Correct the routing or appliance configuration so that the gateway can reach the backend sites.
- Correct: The route table on AppGwSubnet sends backend traffic through a virtual appliance that drops the health probes. The route sends traffic for BackendSubnet to 10.0.9.4, where TCP 80 traffic is dropped. The default probes use the backend HTTP setting's port, so they cannot reach the backend sites.
- Not correct: The NSG on BackendSubnet blocks the health probes from the Application Gateway. The backend NSG allows TCP 80 from AppGwSubnet, and the gateway subnet's NSG does not block outbound TCP 80. The exhibit identifies a drop at the virtual appliance instead.
- Not correct: The backend sites do not respond successfully to the default health probe's host and port. Both sites accept requests on their private IP addresses at port 80 and return HTTP 200 for the default probe's Host header within one second.
- Not correct: The upstream SSL certificate does not match the backend certificate. The backend HTTP setting uses plain HTTP on port 80, so no upstream TLS certificate is involved.
- Not correct: The backend pool is empty or not configured. An empty backend pool can cause 502 errors, but the exhibit shows two backend VM addresses.