why am I gettin 502 bad gateway on ingress-nginx?

11/4/2021

I want to run RabbitMQ management UI from inside a cluster. this is my RabbitMQ deployment file :

...

apiVersion: apps/v1
kind: Deployment
metadata:
  name: rabbitmq-depl
spec:
  replicas: 1
  selector:
    matchLabels:
      app: rabbitmq
  template:
    metadata:
      labels:
        app: rabbitmq
    spec:
      containers:
        - name: rabbitmq
          image: rabbitmq:3.8-management
---
apiVersion: v1
kind: Service
metadata:
  name: rabbitmq-ip
spec:
  selector:
    app: rabbitmq
  ports:
    - name: rabbitmq-client-1
      protocol: TCP
      port: 5671
      targetPort: 5671
    - name: rabbitmq-client-2
      protocol: TCP
      port: 5672
      targetPort: 5672
    - name: rabbitmq-management-1
      protocol: TCP
      port: 15671
      targetPort: 15671
    - name: rabbitmq-management-2
      protocol: TCP
      port: 15672
      targetPort: 15672

...

and this is my ingress-nginx YAML file :

...

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-srv
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/backend-protocol: HTTP
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
  rules:
    - host: ticketing.ir
      http:
        paths:
          - path: /api/v1/auth/?(.*)
            pathType: Prefix
            backend:
              service:
                name: auth-ip
                port:
                  number: 3000
          - path: /api/v1/tickets/?(.*)
            pathType: Prefix
            backend:
              service:
                name: tickets-ip
                port:
                  number: 3000
          - path: /rabbitmq
            pathType: Prefix
            backend:
              service:
                name: rabbitmq-ip
                port:
                  number: 15671

---
apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
  labels:
    app.kubernetes.io/component: controller
  name: nginx
  annotations:
    ingressclass.kubernetes.io/is-default-class: "true"
spec:
  controller: k8s.io/ingress-nginx

...

but when I try to send a get request to ticketing.ir/rabbitmq I get 502 bad gateway Error

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod

-- mostafa nadi
kubernetes
nginx-ingress
rabbitmq

0 Answers