6

I followed the docs here https://learn.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?

3
  • really unclear what you have done and what you havent done >>> very hard to help
    – 4c74356b41
    Aug 2, 2018 at 11:21
  • 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 error
    – itye1970
    Aug 2, 2018 at 12:57
  • 1
    have you set up corresponding hostname in your listeners Sep 19, 2018 at 4:11

2 Answers 2

9

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

1
  • FYI: I had an issue reported as NSG, UDR or Custom DNS ... which turned out to be a bug in the app gateway. The connectivity tester showed all as being OK. By changing the backend pool to a different server, checking the backend health, then reverting to the original backend pool's server it somehow resolved the issue.
    – JohnLBevan
    Nov 8, 2022 at 12:03
1

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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.