- Posted on
- • Linux
Step-by-Step Installation of RabbitMQ on Ubuntu 24.04
- Author
-
-
- User
- edan
- Posts by this author
- Posts by this author
-

RabbitMQ serves as a powerful open-source message broker that facilitates seamless communication between various distributed systems. With support for multiple messaging protocols and a highly extensible architecture, it enhances the reliability and responsiveness of applications while enabling quick integration and deployment. The following instructions will take you through the process of installing RabbitMQ on an Ubuntu 24.04 server, ensuring it is properly secured for use.
Prerequisites
Before starting the installation, prepare the following:
- An active Ubuntu 24.04 instance.
- A domain A record that points to the server's IP address (e.g.,
rabbitmq.example.com
). - SSH access to the server as a non-root user with sudo privileges.
Installing RabbitMQ
RabbitMQ is included in the default Ubuntu package repositories. Start by installing the necessary Erlang and GnuPG packages, along with RabbitMQ itself:
Check the available RabbitMQ package details:
sudo apt-cache policy rabbitmq-server
Install the required dependencies:
sudo apt install gnupg erlang -y
Install RabbitMQ:
sudo apt install rabbitmq-server -y
Managing the RabbitMQ Service
After installation, RabbitMQ runs as a system service. Use the commands below to manage its operations:
Ensure the RabbitMQ service starts automatically on boot:
sudo systemctl enable rabbitmq-server
Start the RabbitMQ service:
sudo systemctl start rabbitmq-server
Confirm that the RabbitMQ service is running properly:
sudo systemctl status rabbitmq-server
You should see output indicating that the service is active and running.
Configuring RabbitMQ
The RabbitMQ management plugin allows access to a web-based interface. Follow these steps to enable the plugin and create an admin user:
Activate the RabbitMQ management plugin:
sudo rabbitmq-plugins enable rabbitmq_management
Create a new admin user with a strong password. Replace
admin
andStrongPassword
with your desired credentials:sudo rabbitmqctl add_user admin StrongPassword
Assign administrator privileges to this user:
sudo rabbitmqctl set_user_tags admin administrator
Grant full permissions to the user:
sudo rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
Securing RabbitMQ
RabbitMQ listens by default on port 15672
. To enhance security, set up Nginx as a reverse proxy:
Setting Up Nginx
Install Nginx:
sudo apt install nginx -y
Enable Nginx to run on startup:
sudo systemctl enable nginx
Start the Nginx service:
sudo systemctl start nginx
Remove the default Nginx configuration:
sudo rm /etc/nginx/sites-enabled/default
Create a new configuration file for RabbitMQ:
sudo nano /etc/nginx/sites-available/rabbitmq.conf
Input the following configuration, replacing
rabbitmq.example.com
with your own domain:server { listen 80; server_name rabbitmq.example.com; location / { proxy_pass http://127.0.0.1:15672; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_redirect off; proxy_http_version 1.1; proxy_max_temp_file_size 0; proxy_cache_bypass $http_upgrade; } }
Enable the new Nginx configuration:
sudo ln -s /etc/nginx/sites-available/rabbitmq.conf /etc/nginx/sites-enabled/
Test the Nginx configuration for correctness:
sudo nginx -t
Restart Nginx to apply the new configuration:
sudo systemctl restart nginx
Allow HTTP connections through the firewall:
sudo ufw allow 80/tcp sudo ufw reload
Securing the Connection with SSL
Use Let's Encrypt to secure your RabbitMQ console with SSL:
Install Certbot:
sudo snap install certbot --classic
Obtain the SSL certificate via the following command. Replace the domain and email with your actual details:
certbot --nginx -d rabbitmq.example.com -m [email protected] --agree-tos
Restart Nginx to implement the SSL configuration:
sudo systemctl restart nginx
Allow HTTPS connections through the firewall:
sudo ufw allow 443/tcp sudo ufw reload
Optionally, restart the RabbitMQ service:
sudo systemctl restart rabbitmq-server
Accessing the RabbitMQ Console
Once everything is set up, visit your domain through a web browser:
https://rabbitmq.example.com
Log in with the admin credentials you created previously. From there, you can access the RabbitMQ management interface and monitor node statistics.
Conclusion
The RabbitMQ installation on Ubuntu 24.04 has been completed successfully, and the application is now secured for handling messages between your applications. For further details or customization, refer to the official RabbitMQ documentation.