Setup rabbitmq service on Ubuntu

Install the rabbitmq server package.

sudo apt-get update 
sudo apt-get install rabbitmq-server

You can enable the management plugin to have a graphical view of the service.

sudo rabbitmq-plugins enable rabbitmq_management
sudo service rabbitmq-server restart

Login with the default guest account (password guest) and create an administrator account for yourself. Then you can repeat this step and create an account for each of the clients connecting to your rabbitMQ. Remember to assign the access and privilege to these accounts because by default they can access nowhere.

To change the configuration, you can edit rabbitmq.config

sudo pico /etc/rabbitmq/rabbitmq.conf

Typically you want to change default port number and enable TLS support for security reason. The instruction to create a self-signed CA can be found here. Below is the configuration you need to add in your config file.

[
 {ssl, [{versions, ['tlsv1.2', 'tlsv1.1']}]},
......
]
[
......
%% Disable non secure port listener.
{tcp_listeners, []},
%% Enable secure port listener.
{ssl_listeners, [56789]},
%% Config the TLS options.
{ssl_options, [{cacertfile,               "/home/ubuntu/msgca/cacert.pem"},
                   {certfile,             "/home/ubuntu/server/cert.pem"},
                   {keyfile,              "/home/ubuntu/server/key.pem"},
                   {verify,               verify_peer},
                   {versions,             ['tlsv1.2', 'tlsv1.1']},
                   {fail_if_no_peer_cert, true}]}
......
]

Then restart your rabbitmq server for the config to be loaded. For development, you can set verify=verify_none and fail_if_no_peer_cert=false


AI Summary
Chrome On-device AI 2024-10-04 22:23:02

Share Article