【问题标题】:Application Gateway - 502 error应用程序网关 - 502 错误
【发布时间】:2017-09-05 02:09:02
【问题描述】:

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

【问题讨论】:

  • 您是否配置了运行状况探测?如果没有运行状况探测,您的所有后端都将被视为已死,这就是 502 的原因。
  • 我添加了一个自定义的健康探测仍然没有解决这个非常令人沮丧的问题。然后,我运行了推荐的 MS Power shell 脚本来创建应用程序网关,并且它工作正常。我检查了每个组件并进行了比较,唯一的区别是因为第二个组件是通过 power-shell 创建的,因此 Health Probe 的主机字段为空。通过门户创建它时,您必须有一个主机名。我说这是通过 Azure 门户创建应用程序网关的错误
  • 假设您的后端是一个负载均衡器,它面向一组托管多个站点的 Web 服务器。您是否同意我的观点,您需要始终明确地使用 Host 标头?

标签: azure azure-application-gateway


【解决方案1】:

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

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

您需要通过资源模板或 Powershell 进行设置。关键是你需要将host字段留空并设置-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

【讨论】:

    猜你喜欢
    • 2016-05-20
    • 2019-05-25
    • 2022-01-12
    • 1970-01-01
    • 2016-01-22
    • 1970-01-01
    • 2019-08-31
    • 2012-05-12
    • 2019-09-07
    相关资源
    最近更新 更多