Azure Application Gateway 502错误

时间:2016-02-10 09:24:05

标签: azure gateway

我正在使用Azure应用程序网关,并坚持以下错误。 在这里,我的网络图 App Gateway with cloud service

这里是我配置的powershell脚本 Poweshell输出     PS C:\ Users \ shabbir.akolawala> Get-AzureApplicationGateway sbr2appgateway

Name          : sbr2appgateway
Description   :
VnetName      : Group Shabs-AppGateway2 sbag2vnet
Subnets       : {sbag2subnet1}
InstanceCount : 2
GatewaySize   : Small
State         : Running
VirtualIPs    : {104.41.159.238} <-- Note IP Here
DnsName       : 01b9b0e4-4cd2-4437-b641-0b5dc4e3efe7.cloudapp.net

此处,应用程序网关的公共IP为104.41.159.238 现在,如果我第一次点击网关,你会得到以下输出 请注意,此网站无法正确呈现,因为许多请求(css / images)因502而失败。

First Response from the Gateway

现在,如果我第二次点击,我会立即得到502错误

enter image description here

但是,当点击云服务IP时,我正确地获取了我的网站

Website render correct with Cloud service

我使用以下配置XML

配置Azure网关

我的问题是,

1]是否有人知道如何访问在Application Gateway中生成的日志(理论上,应用程序网关在IIS 8.5 / ARR上运行)

2]我在设计或配置方面有任何明显错误吗?

3 个答案:

答案 0 :(得分:5)

它是因为超时。 1,Probe默认30秒超时。如果您的应用程序需要身份验证,则必须设置自定义探测。

2,Application Gateway也有默认的30秒超时。如果您的Application Gateway无法从后端虚拟机获得响应。它将返回HTTP 502.它可以通过“ RequestTimeout ”配置项进行更改。

的PowerShell:

  set-AzureApplicationGatewayConfig -Name <application gateway name> -    Configfile "<path to file>"

配置文件:

 <BackendHttpSettings>
    <Name>setting1</Name>
    <Port>80</Port>
    <Protocol>Http</Protocol>
    <CookieBasedAffinity>Enabled</CookieBasedAffinity>
    <RequestTimeout>120</RequestTimeout>
  <Probe>Probe01</Probe> 

详细信息:https://azure.microsoft.com/en-us/documentation/articles/application-gateway-create-probe-classic-ps/

答案 1 :(得分:0)

我创建了自定义健康检查,但从未在websever访问日志中看到过尝试。 所以我只是在后端设置路由来服务任何域,包括IP地址,并为真实域添加htpasswd保护。 Azure应用程序网关检查http://backend_ip:80/并成为开心网关:)

答案 2 :(得分:0)

只需使用资源管理器而不是Classic扩展此@Lang答案即可。以下Powershell脚本将为目标应用程序网关中的每个BackendHttpSetting更新设置新的120秒超时请求。

# Variable setup
$agName = "my gateway name"
$rgName = "my resource group name"
$newRequestTimeout = 120

# Retrieve gateway obj
$appGW = Get-AzureRmApplicationGateway -Name $agName -ResourceGroupName $rgName
$allHttpBackendSettings = Get-AzureRmApplicationGatewayBackendHttpSettings `
-ApplicationGateway $appGW

 foreach($s in $allHttpBackendSettings)
 {  
    # Retreive existing probe
    $probeName = $s.Probe.Id.Split("/") | Select-Object -Last 1;
    $probe = Get-AzureRmApplicationGatewayProbeConfig -ApplicationGateway $appGW `
    -Name $probeName

    # Update http settings 
    $appGW = Set-AzureRmApplicationGatewayBackendHttpSettings -ApplicationGateway $appGW  `
    -Name $s.Name -RequestTimeout $newRequestTimeout -Port $s.Port -Protocol $s.Protocol `
    -Probe $probe -CookieBasedAffinity Enabled  -PickHostNameFromBackendAddress 
 }

# Persist changes to the App Gateway
Set-AzureRmApplicationGateway -ApplicationGateway $appGW