
RabbitMQ is an open-source message broker that enables reliable communication between distributed systems. It supports various messaging protocols and is highly extensible through plugins, making it a useful tool for integrating different applications and ensuring efficient message handling.
This article explains the steps to install and secure RabbitMQ on Ubuntu 22.04.
Before you begin:
Have an Ubuntu 22.04 server.
Create a domain name A record pointing to the server IP address.
Access the server using SSH as a non-root user with sudo privileges.
RabbitMQ is available in the default repositories on Ubuntu 22.04. Follow the steps below to install the Erlang dependency package and RabbitMQ on your server.
Update the server package index.
View the available RabbitMQ APT repository information.
Output:
Install the erlang and gnupg dependency packages.
Install RabbitMQ.
RabbitMQ runs as the rabbitmq-server service on Ubuntu 22.04. Follow the steps below to control the service and ensure the RabbitMQ server is active on your system.
Enable the RabbitMQ service to start at boot time.
Start the RabbitMQ service.
View the RabbitMQ service status and verify that it's running.
Output:
RabbitMQ includes a management plugin that provides a web-based interface for monitoring and configuring the server. Follow the steps below to activate the plugin, create an admin user, and assign full access permissions.
Enable the RabbitMQ management plugin.
Create a new administrative user account with a strong password. Replace admin with your actual user and StrongPassword with your desired user password.
Grant the user administrative privileges.
Grant the user full permissions to all RabbitMQ resources on the server.
Within the above command:
.*: Grants configuration privileges to the user..*: Grants write privileges to the user on any resource..*: Grants read privileges to the user read.RabbitMQ listens for incoming connections on TCP port 15672. To improve security, you can configure a reverse proxy like Nginx to route traffic through a standard port, such as HTTP port 80. Additionally, you can secure connections with SSL certificates to enable HTTPS access, as outlined in the following sections.
Install Nginx.
Enable Nginx to start at boot time.
Start the Nginx service.
Disable the default Nginx configuration file.
Create a new Nginx virtual host configuration such as rabbitmq.conf using a text editor such as nano.
Add the following contents to the file. Replace rabbitmq.example.com with your actual domain.
Save and close the file.
The Nginx configuration sets up a virtual host that listens on HTTP port 80 for your domain rabbitmq.example.com and forwards all requests to RabbitMQ on localhost:15672.
Enable the virtual host configuration.
Test the Nginx configuration for errors.
Restart the Nginx service to apply the configuration changes.
Allow incoming connections to the HTTP port 80 through the default UFW firewall configuration.
Reload UFW to apply your configuration changes.
Install the Certbot Let's Encrypt Client tool.
Generate a new SSL certificate using your domain available in the Nginx virtual host configuration. Replace rabbitmq.example.com and admin@example.com with your actual details.
Restart the Nginx service to apply your SSL configuration changes.
Allow incoming connections to the HTTPS port 443 through the default UFW firewall configuration.
Reload UFW to apply your configuration changes.
Restart the RabbitMQ service.
Access your domain using a web browser such as Chrome to access the RabbitMQ web administration console.
Log in to the RabbitMQ Console using the admin user credentials you created earlier when prompted.
Click Nodes within the RabbitMQ console to view your active node statistics.
In this article, you installed RabbitMQ on an Ubuntu 22.04 server and secured it to enable reliable message streaming between applications.
0 Comments
Be the first to comment and share your perspective with the community.