DEV Community

Cover image for [ByteSize] RabbitMQ management UI and Nginx
Dave O'Dea
Dave O'Dea

Posted on

4 1

[ByteSize] RabbitMQ management UI and Nginx

I originally posted this article on my own site daveodea.com - stop by and say hi!๐Ÿ˜€


Because of the nature of how RabbitMQ structures its API endpoints and for other reasons I won't get into here (hence Byte-size), I've previously struggled with getting the RabbitMQ management plugin UI available at a URL route controlled by Nginx.

Hopefully, this will save you the same headaches I endured ...
Of course, you'll want to make sure you have both RabbitMQ and Nginx installed on your system.

Nginx configuration
Let's firstly setup our nginx.conf file:
sudo vim /etc/nginx/nginx.conf

upstream rabbitmq {
        least_conn;
        server localhost:15672 weight=10 max_fails=3 fail_timeout=30s;
    }
Enter fullscreen mode Exit fullscreen mode

Next, let's edit add location blocks for RabbitMQ:
sudo vim /etc/nginx/sites-enabled/default

location /rabbitmq/api/ {
            rewrite ^ $request_uri;
            rewrite ^/rabbitmq/api/(.*) /api/$1 break;
            return 400;
            proxy_pass http://rabbitmq$uri;
        }
        location /rabbitmq {
            rewrite ^/rabbitmq$ /rabbitmq/ permanent;
            rewrite ^/rabbitmq/(.*)$ /$1 break;
            proxy_pass http://rabbitmq;
            proxy_buffering                    off;
            proxy_set_header Host              $http_host;
            proxy_set_header X-Real-IP         $remote_addr;
            proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }
Enter fullscreen mode Exit fullscreen mode

Reload your Nginx config:
nginx -s reload

Ensure you have the RabbitMQ management plugin enabled:
rabbitmq-plugins enable rabbitmq_management

Now, you can head over to https://your-domain.com/rabbitmq/ and the RabbitMQ login screen will be available.

Thank you for reading,๏ธ
~ Dave


Credit:
Thanks to lukebakken for inspiration I got from their gist on Github, original here.

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

๐Ÿ‘‹ Kindness is contagious

Please leave a โค๏ธ or a friendly comment on this post if you found it helpful!

Okay