<p>I have a ASPNET Core application. when i run this using docker container, it works fine end to end. Then i move the the image to Azure AKS and create a load balancer, browse the web application using IP, and get no issues. But when i create ingress, website loads, register/forget password work on home page but on login click i get 502 bad gateway error. I tried looking at logs using kubectl logs pod -follow but no error popped up.</p>

<p>Have already tried changing images, recreating ingress and running code locally. Error only comes when i click on login button in azure AKS, accessing it via ingress. accessing same pod using load balancer doesnt replicate issue.</p>

<pre><code>apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: devthecrmwebsite
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: devthecrmwebsite
    spec:
      containers:
        - name: devthecrmwebsite
          image: somewhere.azurecr.io/thecrmwebsite:latest
          ports:
            - containerPort: 80
          imagePullPolicy: Always
      imagePullSecrets:
      - name: acr-auth
---
apiVersion: v1
kind: Service
metadata:
    name: devthecrmwebsite
spec:
  ports:
    - name: http-port
      port: 8081
      targetPort: 80
  selector:
    app: devthecrmwebsite
  type: ClusterIP
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: devthecrmwebsite
  labels:
    app: devthecrmwebsite
  annotations:
    kubernetes.io/ingress.class: addon-http-application-routing
spec:
  rules:
  - host: devthecrmwebsite.ac2d980d4f3a4397a96b.southeastasia.aksapp.io
    http:
      paths:
      - backend:
          serviceName: devthecrmwebsite
          servicePort: 8081
        path: /
</code></pre>

<p>I would suggest using wildcard in path , and if you plan to use the code in production you would need Nginx Ingress without using http load balancer routing addon.</p>

<p><a href="https://learn.microsoft.com/en-us/azure/aks/http-application-routing" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/azure/aks/http-application-routing</a></p>

<pre><code>         http:
          paths:
          - backend:
              serviceName: devthecrmwebsite
              servicePort: 80
            path: /(.*)
</code></pre>
