2
votes

I followed the docs here https://docs.microsoft.com/en-us/azure/application-gateway/application-gateway-create-multisite-portal but still getting the error :

Azure Application Gateway error 502 - Web server received an invalid response while acting as a gateway or proxy server. There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, i

Any help?

2
really unclear what you have done and what you havent done >>> very hard to help4c74356b41
Basically I have set up an appgateway as in the link above. Also i have 3 web apps. The app gateway needs to direct traffic from test.mydomain.com, staging.mydomain.com and prod.mydomain,com to the respective webapps test.azurewebsites.net, staging.azurewebsites.net and prod.azurewebsites.net. Multi listeners are set up to listen for the traffic and divert them to the relevant web app but i keep getting the 502 erroritye1970
have you set up corresponding hostname in your listenersSanath Shetty

2 Answers

6
votes

About the 502 errors after configuring the application gateway, The main reasons are as follows.

  • NSG, UDR or Custom DNS is blocking access to backend pool members.
  • Back-end VMs or instances of virtual machine scale set are not responding to the default health probe.
  • Invalid or improper configuration of custom health probes.
  • Azure Application Gateway's back-end pool is not configured or empty.
  • None of the VMs or instances in virtual machine scale set are healthy.
  • Request time-out or connectivity issues with user requests.

References: Troubleshooting bad gateway errors in Application Gateway

Just a reminder, after you changing health probe, please check if you select the use custom probe.

enter image description here

0
votes

Issue: Receiving 502 when you have Web App as the backend pool.

This is how the default probe from Application gateway looks like http/htpps://127.0.0.1:port/

But Web App doesn't respond to localhost, so Application gateway will be receiving 404 for the request sent and it will mark that Web Application unhealthy.

In your scenario, you need to create 3 backend pool where you add one web App in each pool. Then create HTTP setting and enable "Use App Service" check box. How to enable Use App Service

Then create 3 separate rules to achieve your scenario.

Listener1(test.mydomain.com) ---> HTTP Settings (enable Use App Service) --> Backend Pool(test.mydomain.com)

Listener2(staging.mydomain.com) ---> HTTP Settings (enable Use App Service) --> Backend Pool (staging.mydomain.com )

Listener3(prod.mydomain.com) ---> HTTP Settings (enable Use App Service) --> Backend Pool (prod.mydomain.com)