Reputation: 175
Azure application gateway displays 502 bad gateway error
, while application returns 401
or 500 errors
. It should send whatever the application sends but by default it sends 502
. Any idea what happen and any configuration or code change suggestions?
EDIT:
We are using node js
for our API service. When a client tries to hit the endpoint without any auth header
, then the service will return 401 error
. This error is transformed into 502
when it's passing the App gateway.
Upvotes: 1
Views: 6479
Reputation: 11
Error Status Codes(401, 404) returned from pod considered as unhealthy by the azure application gateway and it produces 502 Bad Gateway Error as a response. So you need to modify the health check mechanism of Azure Application Gateway. Error Codes that are considered to be healthy 200-399 by default
Modify it in "health probes" section inside your Application Gateway Resource, https://learn.microsoft.com/en-us/azure/application-gateway/application-gateway-create-probe-portal
Upvotes: 0
Reputation: 382
General Workflow
When application gateway receives a status code greater than 399, then it will consider there were some issues with the servers and it will remove the server from the pool. After sometime it will check the application status, if it is returning status code lesser than 400 then it add the server to pool.
By default application gateway will be configured to check the app health by making a HTTP/HTTPS request.
Cause
Application may encountered any errors or any authentication errors may result in different error codes. This might caused the application gateway result in 502 error.
Probe
We can configure a special file/end point to check the application/database health. This configuration should be in the probe file.
Useful resource
https://azure.microsoft.com/en-us/documentation/articles/application-gateway-probe-overview/
Hope it helps!
Upvotes: 4