@aznsgsub@gmail.com , There might be many reasons for a gateway or proxy server issuing 502 bad gateway error on receiving an invalid response. I would recommend you go through these following checklist troubleshooting steps to find out the exact reason of this error,
Step 1: Check whether the back-end pool is empty
Step2: View the status of the back-end servers --> Check whether all the back-end servers are unhealthy.
Step3: Check whether the problem is caused by a request time-out setting
Procedure:
- If at least one server is healthy, try to increase the request time-out, and then check whether the problem is resolved. To do this, follow these steps:
- In Azure portal, select All resources, and then select the application gateway.
- On the Application gateway blade, select the HTTP settings.
- Select the HTTP setting you created. In the Request Timeout (seconds) box, enter a higher value, such as Or, enter a value that is greater than the number of seconds that your server takes to return the response to every request.
- Click Save.
Step4: Check whether the problem is caused by incorrect rule order
If you have both basic rules and path-based rules, make sure that the path-based rule is set to the higher priority. To change the priority of rules, follow these steps:
- In Azure portal, select All resources, and then select the Application gateway.
- On the Application gateway blade, select Rules.
- Check whether there is a basic type rule that is listed above the multi-site listener rules. If there is, delete the basic type rule, and then create a rule that has the basic listener. The new rule is put at the bottom of the list. In this manner, multi-site rules are prioritized.
Step 5: If your issue persists, please contact Azure Support for further assistance. Let us know if you are looking for a one-time free support so that we can provide you with one.
----------
Please do not forget to "Accept the answer" wherever the information provided helps you to help others in the community.