502 Bad Gateway error when using NestJS app with AKS and AGIC

Camilo Alejandro Moreno Pineros 0 Reputation points
2023-07-28T17:00:01.5166667+00:00

Hey boys, I have a problem and would appreciate if someone could guide me in the right direction.

i'm trying to deploy a backend application made with nestjs to AKS and have it exposed to the internet using Application Gateway Ingress Controller, the deployment of the application works with all the svc, pod and ingress but when i try to access the api with the configured domain in my browser i got a 502 Bad Gateway error

Here is my ingress configuration:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: test
  namespace: default
  annotations:
    kubernetes.io/ingress.class: azure/application-gateway
    cert-manager.io/cluster-issuer: letsencrypt-production
    appgw.ingress.kubernetes.io/ssl-redirect: "true"
    # appgw.ingress.kubernetes.io/backend-path-prefix: "/"
spec:
  tls:
    - hosts:
      - domain.dev
      secretName: app-tls
  rules:
    - host: domain.dev
      http:
        paths:
        # - path: /
        #   pathType: Prefix
        #   backend:
        #     service:
        #       name: app-react
        #       port:
        #         number: 80
        - path: / 
          pathType: Prefix
          backend:
            service:
              name: app-nestjs
              port:
                number: 80

when i make the configuration with a REACT application it works but when i try to do the same with the nest js application the application throws the error (502 Bad Gateway) i have checked both the pod and service and they are running also the ingress shows no error

Name:             test
Labels:           
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.
1,999 questions
{count} votes