RabbitMQ is an open-source message broker implementing AMQP and other protocols, used to decouple producers and consumers across distributed applications. This guide deploys RabbitMQ using Docker Compose with Traefik handling automatic HTTPS for the management UI, with persistent queue storage. By the end, you'll have RabbitMQ running with a secured management dashboard at your domain.
Set Up the Directory Structure
1. Create the project directory:
$ mkdir -p ~/rabbitmq-stack
$ cd ~/rabbitmq-stack
2. Create the environment file:
$ nano .env
DOMAIN=rabbitmq.example.com
LETSENCRYPT_EMAIL=admin@example.com
RABBITMQ_DEFAULT_USER=admin
RABBITMQ_DEFAULT_PASS=STRONG_PASSWORD
Deploy with Docker Compose
1. Create the Docker Compose manifest:
$ nano docker-compose.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
ports:
- "5672:5672"
expose:
- "15672"
volumes:
- "./data:/var/lib/rabbitmq"
- "./logs:/var/log/rabbitmq"
environment:
- RABBITMQ_DEFAULT_USER=${RABBITMQ_DEFAULT_USER}
- RABBITMQ_DEFAULT_PASS=${RABBITMQ_DEFAULT_PASS}
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:
2. Start the services:
$ docker compose up -d
3. Verify the services are running:
$ docker compose ps
$ docker compose logs
Access the RabbitMQ Management Dashboard
Open https://rabbitmq.example.com in a browser. Sign in with RABBITMQ_DEFAULT_USER and RABBITMQ_DEFAULT_PASS from .env. Application clients connect to AMQP on port 5672 at the server's address.
Next Steps
RabbitMQ is running with a secured management UI. From here you can:
- Create vhosts, users, and policies to isolate teams or environments
- Define queues, exchanges, and bindings via the UI or
rabbitmqctl - Enable shovel/federation plugins to bridge clusters across regions
For the full guide with additional tips, visit the original article on Vultr Docs.
Top comments (0)