I have an WAF application gateway in Azure with a backend pool that points to my application. If I visit the gateway address it works and I get the application homepage.
However, if I go to that application and enable PaaS AAD Authentication, which should prompt me with an org login page before getting to my application home page, the gateway stops working and returns message:
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, it received an invalid response from the content server.
When checking backend health I can now see that it is unhealthy, and gives me message:
Probe status code mismatch. Received status code is different from expected 100-999.
Note that I even changed the range to 100-999, just for testing this out. No idea what could be causing this or how to fix it.