
Discover more from Dave O'Dea
[ByteSize] RabbitMQ management UI and Nginx
The [ByteSize] series will be a collection of small, quick solutions to problems that I've come across during my day-to-day software work.
Do you need to have the RabbitMQ interface available at the URL on your domain, but you use Nginx as a reverse proxy? If so, we've got you covered!
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; }
...
Next, let's 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;
}
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 the inspiration I got from their gist on Github, original here.