5

I have RabbitMQ running behind Apache mod_proxy so I can access the web management interface over port 80:

<VirtualHost *:80>
    ServerName rabbit.example.com

    ProxyRequests Off
    ProxyPreserveHost On

    <Proxy *>
       Order deny,allow
       Allow from all
    </Proxy>

    ProxyPass / http://localhost:15672/
    ProxyPassReverse / http://localhost:15672/

    <Location />
       Order allow,deny
       Allow from all
    </Location>
</VirtualHost>

This seems to work however, when I e.g. go to the Queues page and I click on one of the listed queues I get a Not Found page and a URL that looks something like this:

http://rabbit.example.com/#/queues/%2F/myqueue

The same thing goes for Connections, Channels etc. I only seem to be able to access the top pages but anything deeper seems to result in a Not Found.

What is the correct way to configure RabbitMQ behind Apache mod_proxy?

Luke
  • 3,756
  • 7
  • 35
  • 39

1 Answers1

6

First you need to stop apache2.4 from decoding slashes in your path (%2F). To do so set

AllowEncodedSlashes NoDecode

And you need to prevent the escaping of 'dangerous' characters like '#'. With mod_rewrite that would be the [NE] flag, with mod_proxy set

nocanon

This results in:

<VirtualHost *:80>
    ServerName rabbit.example.com

    ProxyRequests Off
    ProxyPreserveHost On

    <Proxy *>
       Order deny,allow
       Allow from all
    </Proxy>

    AllowEncodedSlashes NoDecode
    ProxyPass / http://localhost:15672/ nocanon
    ProxyPassReverse / http://localhost:15672/

    <Location />
       Order allow,deny
       Allow from all
    </Location>
</VirtualHost>
bayoi
  • 76
  • 1
  • 1
    For information, this is covered in the RabbitMQ documentation: https://www.rabbitmq.com/management.html#proxy – Jonathan Ballet Apr 09 '15 at 13:41
  • @JonathanBallet: It's not! I followed the documentation and it partly worked. I could log in and view lists but not detailed items. E.g. could list queues but clicking any specific que was 404. The documentation linked mentions `nocanon` (only for /api which is all that's needed) but doesn't mention `AllowEncodedSlashes NoDecode`. At a guess, the documentation was correct for Apache 2.2 but not for 2.4 – Adam Nov 11 '20 at 19:50
  • the exact solution thanks – John May 08 '21 at 13:08