I am having issues with some requests using the Management UI in docker image rabbitmq:3.6-management behind an Nginx proxy.
I can log in just fine. I can even create a new user. But when I set permissions for a user og try to create an exchange, then I get HTTP 405 in reponse.
I tried copying the request to a cUrl request and this is what I get:
$ curl -i 'http://rabbitmq.xxxx.xx/api/exchanges/%2F/meerkat' -X PUT -H 'Pragma: no-cache' -H 'Origin: http://rabbitmq.xxxx.xx' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: da-DK,da;q=0.8,en-US;q=0.6,en;q=0.4' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36' -H 'content-type: application/json' -H 'Accept: */*' -H 'Cache-Control: no-cache' -H 'authorization: Basic YWRtaW46YWRtaW4=' -H 'Cookie: m=2258:YWRtaW46YWRtaW4%253D' -H 'Connection: keep-alive' -H 'Referer: http://rabbitmq.xxxx.xx/' --data-binary '{"vhost":"/","name":"meerkat","type":"topic","durable":"true","auto_delete":"false","internal":"false","arguments":{}}' --compressed
HTTP/1.1 405 Method Not Allowed
Server: nginx/1.13.1
Date: Mon, 26 Jun 2017 12:04:43 GMT
Content-Length: 0
Connection: keep-alive
vary: origin
allow: HEAD, GET, OPTIONS
Creating a user goes just fine:
curl -i 'http://rabbitmq.xxxx.xx/api/users/test' -X PUT -H 'Pragma: no-cache' -H 'Origin: http://rabbitmq.xxxx.xx' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: da-DK,da;q=0.8,en-US;q=0.6,en;q=0.4' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36' -H 'content-type: application/json' -H 'Accept: */*' -H 'Cache-Control: no-cache' -H 'authorization: Basic YWRtaW46YWRtaW4=' -H 'Cookie: m=2258:YWRtaW46YWRtaW4%253D' -H 'Connection: keep-alive' -H 'Referer: http://rabbitmq.xxxx.xx/' --data-binary '{"username":"test","password":"test","tags":""}' --compressed
HTTP/1.1 201 Created
Server: nginx/1.13.1
Date: Mon, 26 Jun 2017 12:07:26 GMT
Content-Type: application/json
Content-Length: 0
Connection: keep-alive
vary: accept, accept-encoding, origin
@michaelkrog I somewhat doubt this has anything to do with Docker or Nginx. "Setting permissions" and "creating an exchange" are not comparable operations in the sense that they require completely different sets of permissions:
administrator. According to the 2nd curl line, your admin:admin user (base64-decoded from YWRtaW46YWRtaW4=) has that tag./. This is orthogonal to the ability to create new users.RabbitMQ management plugin docs explain how you can enable logging for HTTP API requests to gather more information.
@michaelkrog Don't know if it's still an issue for you, but you probably hit quite known issue of nginx URL normalization - any requests that require virtual host in the uri path ('%2F') does not get proxied correctly through nginx. For details see this.
@azhi Thank you so much. It worked.
(And sorry for the late answer. I have been away for 5 months. ) :smirk:
I came here via a different path, but the %2F in @azhi's answer gave it away. Our tooling specified the URL as
${RABBIT_BASEURL}/api/bindings/${VHOST}/e/${EXCHANGE}/q/${QUEUE%.*}
which failed for a vhost prefixed with a slash (e.g. /test) since that introduced a double slash on the URL (e.g. bindings//test). URL-encoding the vhost (here, to %2Ftest) resolved the issue.
I came to this issue via yet another path, and I fixed it in the Management UI by specifying a new VirtualHost with a normal name without "/" or anything (mine was called "vhosttest"). Having done so, I could successfully make the exchange via the UI, since now the request isn't _"corrupted"_ by a certain vhost name.
Most helpful comment
@michaelkrog Don't know if it's still an issue for you, but you probably hit quite known issue of nginx URL normalization - any requests that require virtual host in the uri path ('%2F') does not get proxied correctly through nginx. For details see this.