---
title: How to Deploy RabbitMQ – Message Broker System
url: https://docs.vultr.com/how-to-deploy-rabbitmq-message-broker-system
description: Deploy RabbitMQ with Docker Compose on Ubuntu 24.04 using Traefik for secure management UI.
publish_date: 2025-12-11T21:45:45.305788Z
last_updated: 2026-09-11T16:41:25.269842Z
author: Aashish Chaurasiya
header_image: https://assets.vultrdevrel.com/docs-main-doc-assets-1/2442/6680b15a-742e-4625-83e2-50271821a246.png
---

> Index of every Vultr Docs page in markdown: https://docs.vultr.com/llms.txt

RabbitMQ is a lightweight message broker that enables applications to communicate asynchronously by sending messages through queues instead of interacting directly. This architecture improves reliability, scalability, and performance across distributed systems.

This article explains how to deploy RabbitMQ using Docker Compose, configure persistent storage for queue data, and secure the RabbitMQ Management UI using Traefik with HTTPS routing.

## Prerequisites

Before you begin, ensure you have:

* Access to an [Ubuntu 24.04-based server](https://www.vultr.com/servers/ubuntu/) as a [non-root user with `sudo` privileges](https://docs.vultr.com/limited-user-login).
* Installed [Docker and Docker Compose](https://docs.vultr.com/how-to-install-docker-on-ubuntu-24-04).
* Created a [DNS A record](https://docs.vultr.com/products/network/dns/management/manage-records) pointing to your server’s IP address (for example, `rabbitmq.example.com`).

## Set Up the Directory Structure and Environment Variables

In this section, you create a project directory for RabbitMQ and define environment variables in a `.env` file that Docker Compose loads automatically.

1. Create the project directory.

    ```console
    $ mkdir -p ~/rabbitmq-stack
    ```

1. Navigate in to the project directory.

    ```console
    $ cd ~/rabbitmq-stack
    ```

1. Create a `.env` file to store the environment variables.

    ```console
    $ nano .env
    ```

    Add the following variables:

    ```ini
    DOMAIN=rabbitmq.example.com
    LETSENCRYPT_EMAIL=admin@example.com

    RABBITMQ_DEFAULT_USER=admin
    RABBITMQ_DEFAULT_PASS=STRONG_PASSWORD
    ```

    Replace:

    * `rabbitmq.example.com` with your domain.
    * `admin@example.com` with your email.
    * `STRONG_PASSWORD` with a secure alphanumeric password.

    Save and close the file.

## Deploy with Docker Compose

In this section, you create the Docker Compose manifest that deploys RabbitMQ and Traefik. Docker Compose uses the `.env` file to inject variables for domain routing, certificate generation, and default RabbitMQ credentials.

1. Create the Docker Compose manifest.

    ```console
    $ nano docker-compose.yaml
    ```

    Add the following content:

    ```yaml
    services:
      traefik:
        image: traefik:v3.6
        container_name: traefik
        command:
          - "--providers.docker=true"
          - "--providers.docker.exposedbydefault=false"
          - "--entrypoints.web.address=:80"
          - "--entrypoints.websecure.address=:443"
          - "--entrypoints.web.http.redirections.entrypoint.to=websecure"
          - "--entrypoints.web.http.redirections.entrypoint.scheme=https"
          - "--certificatesresolvers.letsencrypt.acme.httpchallenge=true"
          - "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web"
          - "--certificatesresolvers.letsencrypt.acme.email=${LETSENCRYPT_EMAIL}"
          - "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
        ports:
          - "80:80"
          - "443:443"
        volumes:
          - "letsencrypt:/letsencrypt"
          - "/var/run/docker.sock:/var/run/docker.sock:ro"
        restart: unless-stopped

      rabbitmq:
        image: rabbitmq:4.2-management
        container_name: rabbitmq
        hostname: rabbitmq
        environment:
          - RABBITMQ_DEFAULT_USER=${RABBITMQ_DEFAULT_USER}
          - RABBITMQ_DEFAULT_PASS=${RABBITMQ_DEFAULT_PASS}
        ports:
          - "5672:5672"
        expose:
          - "15672"
        volumes:
          - "rabbitmq-lib:/var/lib/rabbitmq"
          - "rabbitmq-log:/var/log/rabbitmq"
        labels:
          - "traefik.enable=true"
          - "traefik.http.routers.rabbitmq.rule=Host(`${DOMAIN}`)"
          - "traefik.http.routers.rabbitmq.entrypoints=websecure"
          - "traefik.http.routers.rabbitmq.tls.certresolver=letsencrypt"
          - "traefik.http.services.rabbitmq.loadbalancer.server.port=15672"
        restart: unless-stopped

    volumes:
      letsencrypt:
      rabbitmq-lib:
      rabbitmq-log:
    ```

    Save and close the file.

    In this manifest:

    * **services**: Defines the containers managed by Docker Compose:
        * **traefik**: Acts as the reverse proxy, handles HTTPS termination, manages routing, and automatically generates Let's Encrypt certificates.
        * **rabbitmq**: Runs the RabbitMQ server and exposes the Management UI.
    * **image**: Specifies the container image used for each service.
    * **container_name**: Assigns a fixed container name to simplify logging and container management.
    * **command (Traefik)**: Configures Traefik with Docker service discovery, HTTP/HTTPS entry points, automatic HTTP→HTTPS redirection, and ACME (Let’s Encrypt) certificate generation.
    * **ports (Traefik)**: Publishes ports `80` and `443` on the host so Traefik can receive and route all incoming traffic.
    * **ports (RabbitMQ)**: Maps port `5672`, the primary AMQP messaging port, to the host.
    * **expose (RabbitMQ)**: Exposes port `15672` (RabbitMQ Management UI) to Traefik internally without exposing it directly to the host machine.
    * **volumes**:
        * `rabbitmq-lib` stores RabbitMQ’s persistent message/queue data.
        * `rabbitmq-log` stores RabbitMQ log files.
        * `letsencrypt` stores TLS certificates generated by Traefik.
        * `/var/run/docker.sock` allows Traefik to detect running Docker services automatically.
    * **labels (RabbitMQ)**: Enables Traefik for the container, defines the domain-based routing rule, selects the HTTPS entry point, and specifies the internal port (`15672`) Traefik should forward requests to.
    * **restart: unless-stopped**: Ensures the service automatically restarts unless manually stopped.

1. Start the services.

    ```console
    $ docker compose up -d
    ```

1. Verify that both services are running.

    ```console
    $ docker compose ps
    ```

    Output:

    ```
    NAME       IMAGE                     COMMAND                  SERVICE    CREATED       STATUS       PORTS
    rabbitmq   rabbitmq:4.2-management   "docker-entrypoint.s…"   rabbitmq   2 hours ago   Up 2 hours   4369/tcp, 5671/tcp, ...
    traefik    traefik:v3.6              "/entrypoint.sh --pr…"   traefik    2 hours ago   Up 2 hours   0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, ...
    ```

    The above output confirms that both services are running successfully.

1. View the logs for the services.

    ```console
    $ docker compose logs
    ```

    For more information on managing a Docker Compose stack, see the [How To Use Docker Compose](https://docs.vultr.com/how-to-use-docker-compose) article.

## Access the RabbitMQ Management Dashboard

In this section, you open the RabbitMQ Management UI using the domain you configured and verify that the dashboard loads correctly.

1. Open the RabbitMQ Management Dashboard in your browser.

    ```
    https://rabbitmq.example.com
    ```

1. Log in using the credentials you configured in your `.env` file.
1. After successful authentication, the RabbitMQ Management Dashboard appears.

    ![RabbitMQ Management Dashboard](https://assets.vultrdevrel.com/docs-main-doc-assets-1/2442/9f97181c-55d2-40b8-bd4a-1d25f6a923e4.png)

## Conclusion

You have successfully deployed RabbitMQ with the Management UI using Docker Compose and Traefik. Traefik handled HTTPS and routing for the management dashboard, and RabbitMQ stored data and logs on persistent host volumes. You can now create admin users, manage queues via the dashboard, and connect applications to RabbitMQ on port `5672`.
