An organization deploys an Azure App Service named app-prod-01 that hosts a web application at the default URL app-prod-01.azurewebsites.net. You configure an Azure Application Gateway v2 to publish the web application to the public internet using the custom domain name www.contoso.com. You configure a DNS CNAME record for www.contoso.com pointing to the public IP address of the Application Gateway. You add app-prod-01.azurewebsites.net as a target in the backend pool of the Application Gateway. When users attempt to access https://www.contoso.com, they receive an HTTP 502 (Bad Gateway) error. What should you do on the Application Gateway to resolve the error?
- In the Backend Settings of the Application Gateway, enable the host name override and choose to pick the host name from the backend target.Cevap
- BIn the App Service Plan configuration, scale down the pricing tier to Free (F1) to disable the default custom domain hostname verification.
- CCreate a User-Defined Route (UDR) on the Application Gateway subnet that specifies the App Service IP address as the next hop with a type of Virtual Network Gateway.
- DCreate an inbound security rule in the Network Security Group (NSG) associated with the Application Gateway subnet that denies traffic from the GatewayManager service tag with a priority of 150.
Cevap
In the Backend Settings of the Application Gateway, enable the host name override and choose to pick the host name from the backend target.
Azure App Service requires that the incoming HTTP host header matches either its default '*.azurewebsites.net' domain name or an explicitly configured custom domain name. By default, Azure Application Gateway preserves the original host header from the client request (in this case, 'www.contoso.com') when forwarding traffic to the backend. Since the App Service is not configured with 'www.contoso.com', it rejects the request, causing the Application Gateway to return an HTTP 502 Bad Gateway error. Enabling the host name override option and picking the host name from the backend target in the Backend Settings ensures that the Application Gateway rewrites the host header to 'app-prod-01.azurewebsites.net' before forwarding the request.
Adım Adım Çözüm
Anahtar Kavram
Configuring backend settings and host header overrides in Azure Application Gateway for App Service integration