Ingress 502 bad gateway only when I click login, other pages like forgot password/register work ok

10/3/2019

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.

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.

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: /
-- Rajan Bhayana
azure
azure-aks
kubernetes

2 Answers

10/3/2019

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.

https://docs.microsoft.com/en-us/azure/aks/http-application-routing

         http:
          paths:
          - backend:
              serviceName: devthecrmwebsite
              servicePort: 80
            path: /(.*)
-- Anass Kartit
Source: StackOverflow

10/3/2019

turned out to be nginx settings issue. for azure aks - - get the deployment name of default http nginx ingress controller. kubectl get deployment -n kube-system

then checked the logs of ingress controller kubectl logs -f deploy/addon-http-application-routing-nginx-ingress-controller -n kube-system --tail 100

finally found a relevant error log - upstream sent too big header while reading response header from upstream

lot of articles online for this specific issue.

-- Rajan Bhayana
Source: StackOverflow