Skip to content

Commit 4ebb182

Browse files
authored
Merge pull request #74685 from vhorne/ag-http-settings
Update timeout setting, and a bunch of edits
2 parents 8b21f3d + 1447f7f commit 4ebb182

File tree

1 file changed

+45
-44
lines changed

1 file changed

+45
-44
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,56 @@
11
---
2-
title: Troubleshoot Azure Application Gateway Bad Gateway (502) errors | Microsoft Docs
2+
title: Troubleshoot Azure Application Gateway Bad Gateway (502) errors
33
description: Learn how to troubleshoot Application Gateway 502 errors
44
services: application-gateway
5-
documentationcenter: na
6-
author: amitsriva
7-
manager: rossort
8-
editor: ''
9-
tags: azure-resource-manager
10-
11-
ms.assetid: 1d431ead-d318-47d8-b3ad-9c69f7e08813
5+
author: vhorne
126
ms.service: application-gateway
13-
ms.devlang: na
147
ms.topic: article
15-
ms.tgt_pltfrm: na
16-
ms.workload: infrastructure-services
17-
ms.date: 05/09/2017
8+
ms.date: 4/25/2019
189
ms.author: amsriva
19-
2010
---
2111

2212
# Troubleshooting bad gateway errors in Application Gateway
2313

24-
Learn how to troubleshoot bad gateway (502) errors received when using application gateway.
14+
Learn how to troubleshoot bad gateway (502) errors received when using Azure Application Gateway.
2515

2616
[!INCLUDE [updated-for-az](../../includes/updated-for-az.md)]
2717

2818
## Overview
2919

30-
After configuring an application gateway, one of the errors that users may encounter is "Server Error: 502 - Web server received an invalid response while acting as a gateway or proxy server". This error may happen due to the following main reasons:
20+
After configuring an application gateway, one of the errors that you may see is "Server Error: 502 - Web server received an invalid response while acting as a gateway or proxy server". This error may happen for the following main reasons:
3121

32-
* NSG, UDR or Custom DNS is blocking access to backend pool members.
33-
* Back-end VMs or instances of virtual machine scale set are not responding to the default health probe.
22+
* NSG, UDR, or Custom DNS is blocking access to backend pool members.
23+
* Back-end VMs or instances of virtual machine scale set aren't responding to the default health probe.
3424
* Invalid or improper configuration of custom health probes.
35-
* Azure Application Gateway's [back-end pool is not configured or empty](#empty-backendaddresspool).
25+
* Azure Application Gateway's [back-end pool isn't configured or empty](#empty-backendaddresspool).
3626
* None of the VMs or instances in [virtual machine scale set are healthy](#unhealthy-instances-in-backendaddresspool).
3727
* [Request time-out or connectivity issues](#request-time-out) with user requests.
3828

3929
## Network Security Group, User Defined Route, or Custom DNS issue
4030

4131
### Cause
4232

43-
If access to backend is blocked due to presence of NSG, UDR or custom DNS, Application Gateway instances will not be able to reach the backend pool and would result in probe failures causing 502 errors. Note that the NSG/UDR could be present either in Application Gateway subnet or the subnet where the application VMs are deployed. Similarly presence of custom DNS in the VNET could also cause issues if FQDN is used for backend pool members and is not resolved correctly by the user configured DNS server for the VNET.
33+
If access to the backend is blocked because of an NSG, UDR, or custom DNS, application gateway instances can't reach the backend pool. This causes probe failures, resulting in 502 errors.
34+
35+
The NSG/UDR could be present either in the application gateway subnet or the subnet where the application VMs are deployed.
36+
37+
Similarly, the presence of a custom DNS in the VNet could also cause issues. A FQDN used for backend pool members might not resolve correctly by the user configured DNS server for the VNet.
4438

4539
### Solution
4640

4741
Validate NSG, UDR, and DNS configuration by going through the following steps:
48-
* Check NSGs associated with Application Gateway subnet. Ensure that communication to backend is not blocked.
49-
* Check UDR associated with Application Gateway subnet. Ensure that UDR is not directing traffic away from backend subnet - for example check for routing to network virtual appliances or default routes being advertised to Application Gateway subnet via ExpressRoute/VPN.
5042

51-
```powershell
43+
* Check NSGs associated with the application gateway subnet. Ensure that communication to backend isn't blocked.
44+
* Check UDR associated with the application gateway subnet. Ensure that the UDR isn't directing traffic away from the backend subnet. For example, check for routing to network virtual appliances or default routes being advertised to the application gateway subnet via ExpressRoute/VPN.
45+
46+
```azurepowershell
5247
$vnet = Get-AzVirtualNetwork -Name vnetName -ResourceGroupName rgName
5348
Get-AzVirtualNetworkSubnetConfig -Name appGwSubnet -VirtualNetwork $vnet
5449
```
5550

5651
* Check effective NSG and route with the backend VM
5752

58-
```powershell
53+
```azurepowershell
5954
Get-AzEffectiveNetworkSecurityGroup -NetworkInterfaceName nic1 -ResourceGroupName testrg
6055
Get-AzEffectiveRouteTable -NetworkInterfaceName nic1 -ResourceGroupName testrg
6156
```
@@ -70,13 +65,17 @@ DhcpOptions : {
7065
]
7166
}
7267
```
73-
If present, ensure that the DNS server is able to resolve backend pool member's FQDN correctly.
68+
If present, ensure that the DNS server can resolve the backend pool member's FQDN correctly.
7469

7570
## Problems with default health probe
7671

7772
### Cause
7873

79-
502 errors can also be frequent indicators that the default health probe is not able to reach back-end VMs. When an Application Gateway instance is provisioned, it automatically configures a default health probe to each BackendAddressPool using properties of the BackendHttpSetting. No user input is required to set this probe. Specifically, when a load balancing rule is configured, an association is made between a BackendHttpSetting and BackendAddressPool. A default probe is configured for each of these associations and Application Gateway initiates a periodic health check connection to each instance in the BackendAddressPool at the port specified in the BackendHttpSetting element. Following table lists the values associated with the default health probe.
74+
502 errors can also be frequent indicators that the default health probe can't reach back-end VMs.
75+
76+
When an application gateway instance is provisioned, it automatically configures a default health probe to each BackendAddressPool using properties of the BackendHttpSetting. No user input is required to set this probe. Specifically, when a load-balancing rule is configured, an association is made between a BackendHttpSetting and a BackendAddressPool. A default probe is configured for each of these associations and the application gateway starts a periodic health check connection to each instance in the BackendAddressPool at the port specified in the BackendHttpSetting element.
77+
78+
The following table lists the values associated with the default health probe:
8079

8180
| Probe property | Value | Description |
8281
| --- | --- | --- |
@@ -89,66 +88,68 @@ If present, ensure that the DNS server is able to resolve backend pool member's
8988

9089
* Ensure that a default site is configured and is listening at 127.0.0.1.
9190
* If BackendHttpSetting specifies a port other than 80, the default site should be configured to listen at that port.
92-
* The call to `http://127.0.0.1:port` should return an HTTP result code of 200. This should be returned within the 30 sec time-out period.
93-
* Ensure that port configured is open and that there are no firewall rules or Azure Network Security Groups, which block incoming or outgoing traffic on the port configured.
94-
* If Azure classic VMs or Cloud Service is used with FQDN or Public IP, ensure that the corresponding [endpoint](../virtual-machines/windows/classic/setup-endpoints.md?toc=%2fazure%2fapplication-gateway%2ftoc.json) is opened.
95-
* If the VM is configured via Azure Resource Manager and is outside the VNet where Application Gateway is deployed, [Network Security Group](../virtual-network/security-overview.md) must be configured to allow access on the desired port.
91+
* The call to `http://127.0.0.1:port` should return an HTTP result code of 200. This should be returned within the 30-second timeout period.
92+
* Ensure that the port configured is open and that there are no firewall rules or Azure Network Security Groups, which block incoming or outgoing traffic on the port configured.
93+
* If Azure classic VMs or Cloud Service is used with a FQDN or a public IP, ensure that the corresponding [endpoint](../virtual-machines/windows/classic/setup-endpoints.md?toc=%2fazure%2fapplication-gateway%2ftoc.json) is opened.
94+
* If the VM is configured via Azure Resource Manager and is outside the VNet where the application gateway is deployed, a [Network Security Group](../virtual-network/security-overview.md) must be configured to allow access on the desired port.
9695

9796
## Problems with custom health probe
9897

9998
### Cause
10099

101-
Custom health probes allow additional flexibility to the default probing behavior. When using custom probes, users can configure the probe interval, the URL, and path to test, and how many failed responses to accept before marking the back-end pool instance as unhealthy. The following additional properties are added.
100+
Custom health probes allow additional flexibility to the default probing behavior. When you use custom probes, you can configure the probe interval, the URL, the path to test, and how many failed responses to accept before marking the back-end pool instance as unhealthy.
101+
102+
The following additional properties are added:
102103

103104
| Probe property | Description |
104105
| --- | --- |
105106
| Name |Name of the probe. This name is used to refer to the probe in back-end HTTP settings. |
106107
| Protocol |Protocol used to send the probe. The probe uses the protocol defined in the back-end HTTP settings |
107-
| Host |Host name to send the probe. Applicable only when multi-site is configured on Application Gateway. This is different from VM host name. |
108+
| Host |Host name to send the probe. Applicable only when multi-site is configured on the application gateway. This is different from VM host name. |
108109
| Path |Relative path of the probe. The valid path starts from '/'. The probe is sent to \<protocol\>://\<host\>:\<port\>\<path\> |
109110
| Interval |Probe interval in seconds. This is the time interval between two consecutive probes. |
110-
| Time-out |Probe time-out in seconds. If a valid response is not received within this time-out period, the probe is marked as failed. |
111+
| Time-out |Probe time-out in seconds. If a valid response isn't received within this time-out period, the probe is marked as failed. |
111112
| Unhealthy threshold |Probe retry count. The back-end server is marked down after the consecutive probe failure count reaches the unhealthy threshold. |
112113

113114
### Solution
114115

115116
Validate that the Custom Health Probe is configured correctly as the preceding table. In addition to the preceding troubleshooting steps, also ensure the following:
116117

117118
* Ensure that the probe is correctly specified as per the [guide](application-gateway-create-probe-ps.md).
118-
* If Application Gateway is configured for a single site, by default the Host name should be specified as `127.0.0.1`, unless otherwise configured in custom probe.
119+
* If the application gateway is configured for a single site, by default the Host name should be specified as `127.0.0.1`, unless otherwise configured in custom probe.
119120
* Ensure that a call to http://\<host\>:\<port\>\<path\> returns an HTTP result code of 200.
120-
* Ensure that Interval, Time-out and UnhealtyThreshold are within the acceptable ranges.
121+
* Ensure that Interval, Timeout, and UnhealtyThreshold are within the acceptable ranges.
121122
* If using an HTTPS probe, make sure that the backend server doesn't require SNI by configuring a fallback certificate on the backend server itself.
122123

123124
## Request time-out
124125

125126
### Cause
126127

127-
When a user request is received, Application Gateway applies the configured rules to the request and routes it to a back-end pool instance. It waits for a configurable interval of time for a response from the back-end instance. By default, this interval is **30 seconds**. If Application Gateway does not receive a response from back-end application in this interval, user request would see a 502 error.
128+
When a user request is received, the application gateway applies the configured rules to the request and routes it to a back-end pool instance. It waits for a configurable interval of time for a response from the back-end instance. By default, this interval is **20** seconds. If the application gateway does not receive a response from back-end application in this interval, the user request gets a 502 error.
128129

129130
### Solution
130131

131-
Application Gateway allows users to configure this setting via BackendHttpSetting, which can be then applied to different pools. Different back-end pools can have different BackendHttpSetting and hence different request time-out configured.
132+
Application Gateway allows you to configure this setting via the BackendHttpSetting, which can be then applied to different pools. Different back-end pools can have different BackendHttpSetting, and a different request time-out configured.
132133

133-
```powershell
134+
```azurepowershell
134135
New-AzApplicationGatewayBackendHttpSettings -Name 'Setting01' -Port 80 -Protocol Http -CookieBasedAffinity Enabled -RequestTimeout 60
135136
```
136137

137138
## Empty BackendAddressPool
138139

139140
### Cause
140141

141-
If the Application Gateway has no VMs or virtual machine scale set configured in the back-end address pool, it cannot route any customer request and throws a bad gateway error.
142+
If the application gateway has no VMs or virtual machine scale set configured in the back-end address pool, it can't route any customer request and sends a bad gateway error.
142143

143144
### Solution
144145

145-
Ensure that the back-end address pool is not empty. This can be done either via PowerShell, CLI, or portal.
146+
Ensure that the back-end address pool isn't empty. This can be done either via PowerShell, CLI, or portal.
146147

147-
```powershell
148+
```azurepowershell
148149
Get-AzApplicationGateway -Name "SampleGateway" -ResourceGroupName "ExampleResourceGroup"
149150
```
150151

151-
The output from the preceding cmdlet should contain non-empty back-end address pool. Following is an example where two pools are returned which are configured with FQDN or IP addresses for backend VMs. The provisioning state of the BackendAddressPool must be 'Succeeded'.
152+
The output from the preceding cmdlet should contain non-empty back-end address pool. The following example shows two pools returned which are configured with a FQDN or an IP addresses for the backend VMs. The provisioning state of the BackendAddressPool must be 'Succeeded'.
152153

153154
BackendAddressPoolsText:
154155

@@ -180,13 +181,13 @@ BackendAddressPoolsText:
180181

181182
### Cause
182183

183-
If all the instances of BackendAddressPool are unhealthy, then Application Gateway would not have any back-end to route user request to. This could also be the case when back-end instances are healthy but do not have the required application deployed.
184+
If all the instances of BackendAddressPool are unhealthy, then the application gateway doesn't have any back-end to route user request to. This can also be the case when back-end instances are healthy but don't have the required application deployed.
184185

185186
### Solution
186187

187-
Ensure that the instances are healthy and the application is properly configured. Check if the back-end instances are able to respond to a ping from another VM in the same VNet. If configured with a public end point, ensure that a browser request to the web application is serviceable.
188+
Ensure that the instances are healthy and the application is properly configured. Check if the back-end instances can respond to a ping from another VM in the same VNet. If configured with a public end point, ensure a browser request to the web application is serviceable.
188189

189190
## Next steps
190191

191-
If the preceding steps do not resolve the issue, open a [support ticket](https://azure.microsoft.com/support/options/).
192+
If the preceding steps don't resolve the issue, open a [support ticket](https://azure.microsoft.com/support/options/).
192193

0 commit comments

Comments
 (0)