<p>I am trying to setup a RabbitMQ tasks queue in a kubernetes cluster and need to be able to populate the task queue from outside of the kubernetes cluster. I am trying to accomplish this using the nginx ingress controller. I am running into errors when trying to declare a queue or send messages to an existing queue from outside of the cluster. Using the amqp-tools cli in Ubuntu from outside the cluster I get an error:</p>

<pre><code>$ export BROKER_URL=amqp://&lt;host-name&gt;:80/rabbitmq
$ /usr/bin/amqp-declare-queue --url=$BROKER_URL -q foo -d

logging in to AMQP server: invalid AMQP data
</code></pre>

<p>If I do this same thing from a VM inside the cluster, I can create and send message to the queue just fine. I am also able to connect to the RabbitMQ management UI from outside of the cluster but if I try to declare a queue from the UI I get the error <code>Management API returned status code 405 -</code> displayed at the bottom of the screen.</p>

<p>I was reading that the virtual host in RabbitMQ '/' has problems with nginx because of how it parses the host but I am not very experienced with this sort of thing and dont know how to fix that.</p>

<p>Any help with this would be greatly appreciated.</p>

<p>I am deploying the nginx ingress controller with the recommended manifest:</p>

<pre><code>kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/mandatory.yaml
</code></pre>

<p>RabbitMQ is deployed with this manifest:</p>

<pre><code>---
apiVersion: v1
kind: Namespace
metadata:
  name: rabbitmq
  labels:
    app: rabbitmq
---
apiVersion: v1
kind: Service
metadata:
  name: rabbitmq-service
  namespace: rabbitmq
  labels:
    component: rabbitmq
spec:
  type: ClusterIP
  ports:
  - name: amqp
    port: 5672
    targetPort: 5672
    protocol: TCP
  - name: http
    port: 80
    targetPort: 15672
    protocol: TCP
  selector:
    app: taskQueue
    component: rabbitmq
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: rabbit-ingress
  namespace: rabbitmq
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
  rules:
  - host: &lt;host-name&gt;
    http:
      paths:
      - path: /rabbitmq/?(.*)
        backend:
          serviceName: rabbitmq-service
          servicePort: 5672
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: rabbit-manage-ingress
  namespace: rabbitmq
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
  rules:
  - host: &lt;host-name&gt;
    http:
      paths:
      - path: /rabbitmq-manage/?(.*)
        backend:
          serviceName: rabbitmq-service
          servicePort: 80
---
apiVersion: v1
kind: ReplicationController
metadata:
  labels:
    app: taskQueue
    component: rabbitmq
  name: rabbitmq-controller
  namespace: rabbitmq
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: taskQueue
        component: rabbitmq
    spec:
      containers:
      - image: rabbitmq:3-management
        name: rabbitmq
        ports:
        - containerPort: 5672
        - containerPort: 15672
        resources:
          limits:
            cpu: 100m
</code></pre>

<p>As far as i know, RabbitMQ does not provide a HTTP-API for interacting (at least it's not the default). NGINX-Ingress cannot use an Ingress resource to expose anything different to a HTTP-Service. <a href="https://kubernetes.github.io/ingress-nginx/user-guide/exposing-tcp-udp-services/" rel="nofollow noreferrer">Take a look at the documentation to learn how to expose a TCP- or UDP-Based service</a>.</p>
