应用程序网关 - 502 错误

Application Gateway - 502 error

我按照MS文档设置了一个新的应用程序网关。我已经配置了后端池。它通过 FQDN 连接到应用服务。每次浏览到应用程序网关时,我都会以某种方式立即收到 502。直接浏览网站没有问题。

我已经解决了这个问题。这是解决方案。

如果后端池中有 Web 应用程序,则无法通过 Azure 门户设置运行状况探测。

您需要通过资源模板或 Powershell 进行设置。关键是你需要将主机字段留空并设置 -PickHostNameFromBackendAddress 属性.

The two lines below did the magic to make the 502s go away

# Create a probe with the PickHostNameFromBackendHttpSettings switch for web apps
$probeconfig = New-AzureRmApplicationGatewayProbeConfig -name webappprobe -Protocol Http -Path / -Interval 30 -Timeout 120 -UnhealthyThreshold 3 -PickHostNameFromBackendHttpSettings    

# Define the backend http settings
$poolSetting = New-AzureRmApplicationGatewayBackendHttpSettings -Name appGatewayBackendHttpSettings -Port 80 -Protocol Http -CookieBasedAffinity Disabled -RequestTimeout 120 -PickHostNameFromBackendAddress -Probe $probeconfig