application gateway ingress return 502 error

Loraine Sum 0 Reputation points
2024-05-09T09:17:53.68+00:00

I am unable to hit my backend endpoint via application gateway load balancer. It returns error 502 Bad Gateway.

Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
1,079 questions
Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,144 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Prrudram-MSFT 25,156 Reputation points
    2024-05-14T06:50:36.5633333+00:00

    Hi @Loraine Sum

    Setting up an Application Gateway Ingress Controller (AGIC) in Azure and encountering a 502 error can be challenging. The 502 Bad Gateway error indicates that the gateway received an invalid response from the upstream server, which in this case is your AKS pod. Since you’ve checked the backend health and it returns a 404 error with HTTP protocol, this suggests that the AGIC is able to communicate with the pod, but the specific resource it’s trying to access is not found.

    Here are some steps you can take to troubleshoot the issue further:

    Verify the Ingress Resource: Ensure that the Ingress resource is correctly configured to route traffic to your service. You can check this with the command kubectl get ingress.

    Check the Service Configuration: Make sure that the service is active and properly configured to route traffic to the correct port on your pod. Use kubectl get svc to verify the service details.

    Inspect the Pod’s Logs: Look at the logs of the pod to see if there are any errors or messages that could indicate why it’s returning a 404. Use kubectl logs <pod-name>.

    Review AGIC Logs: Check the logs of the AGIC pod to see if there are any errors or messages related to the configuration or routing. Use kubectl logs <agic-pod-name>.

    Test with a Simple App: Deploy a simple application to ensure that the Application Gateway, AKS, and AGIC setup is correct. This can help isolate whether the issue is with your specific application or the infrastructure setup1.

    Check for SSL/TLS Issues: If you’re using SSL/TLS, ensure that the certificates are correctly configured and that the AGIC is able to use them.

    Review Annotations: Annotations in your Ingress resource can affect how traffic is routed. Make sure that they are correctly set. For example, if you’re not using Nginx, avoid using annotations specific to Nginx Ingress Controller.

    Path-Based Routing: If you’re using path-based routing, ensure that the paths are correctly defined in your Ingress resource and that your application is configured to handle those paths.

    If you’ve already followed the official troubleshooting documentation and these steps without success, it might be helpful to reach out to Azure support for more in-depth assistance. They can provide more targeted help based on the specifics of your Azure environment and configuration. If I have answered your query, please click "Accept as answer" as a token of appreciation

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.