2

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

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 logs show the application starting with no errors

I have tried with the following command kubectl port-forward svc/app-nestjs -n default 8082:80 and tested the nestjs application, it works as expected.

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

the ingress shows no error:

Name:             test
Labels:           <none>
Namespace:        default
Address:          xx.xxx.xx.xxx
Ingress Class:    <none>
Default backend:  <default>
TLS:
  app-tls terminates domain.dev
Rules:
  Host          Path  Backends
  ----          ----  --------
  domain.dev  
                /   app-nestjs:80 (192.168.0.53:80)
Annotations:    appgw.ingress.kubernetes.io/ssl-redirect: true
                cert-manager.io/cluster-issuer: letsencrypt-production
                kubernetes.io/ingress.class: azure/application-gateway
Events:         <none>

Is there a way of debugging the ingress controller or application gateway to see what may be happening?

has any of you had to do a similar configuration and have a proper solution to this?

zoluxero
  • 61
  • 5
  • 1
    Have you already resolved it? I have a similar issue, and I struggle yet with this. – chenio Jul 28 '23 at 19:41
  • 1
    nothing yet i tried exposing the api like so: https://stackoverflow.com/questions/65245356/cant-serve-traefik-nestjs-app-in-kubernetes-bad-gateway still not working – zoluxero Jul 28 '23 at 19:45
  • I'll review that aditional config on my app. thank you, I keep in touch – chenio Jul 28 '23 at 23:26

0 Answers0