RabbitMQ connection impossible from another service

Hi, I'm trying to setup RabbitMQ and connect from another service on my Dokploy managed server. Here is the compose file:
services:
rabbitmq:
image: rabbitmq:4.0.4-management-alpine
restart: unless-stopped
environment:
RABBITMQ_DEFAULT_USER: ${RABBITMQ_DEFAULT_USER}
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_DEFAULT_PASS}
volumes:
- rabbitmq_data:/var/lib/rabbitmq/
networks:
- dokploy-network
labels:
- traefik.enable=true
- traefik.http.routers.alfred-staging-message-broker-ueiasj-38-web.rule=HostSNI(`broker.example.com`)
- traefik.http.routers.alfred-staging-message-broker-ueiasj-38-web.entrypoints=rabbitmq
- traefik.http.services.alfred-staging-message-broker-ueiasj-38-web.loadbalancer.server.port=5672
- traefik.http.services.alfred-staging-message-broker-ueiasj-38-web.tls.certresolver==letsencrypt
- traefik.http.routers.alfred-staging-message-broker-ueiasj-38-web.service=alfred-staging-message-broker-ueiasj-38-web

volumes:
rabbitmq_data:
services:
rabbitmq:
image: rabbitmq:4.0.4-management-alpine
restart: unless-stopped
environment:
RABBITMQ_DEFAULT_USER: ${RABBITMQ_DEFAULT_USER}
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_DEFAULT_PASS}
volumes:
- rabbitmq_data:/var/lib/rabbitmq/
networks:
- dokploy-network
labels:
- traefik.enable=true
- traefik.http.routers.alfred-staging-message-broker-ueiasj-38-web.rule=HostSNI(`broker.example.com`)
- traefik.http.routers.alfred-staging-message-broker-ueiasj-38-web.entrypoints=rabbitmq
- traefik.http.services.alfred-staging-message-broker-ueiasj-38-web.loadbalancer.server.port=5672
- traefik.http.services.alfred-staging-message-broker-ueiasj-38-web.tls.certresolver==letsencrypt
- traefik.http.routers.alfred-staging-message-broker-ueiasj-38-web.service=alfred-staging-message-broker-ueiasj-38-web

volumes:
rabbitmq_data:
I can connect to the rabbitmq dashboard but can't use it from my Symfony app using this DSN URL amqp://user:[email protected]:5672/%2f
8 Replies
ElPoulpo
ElPoulpoOP6mo ago
Also tried that
rabbitmq:
image: rabbitmq:4.0.4-management-alpine
restart: unless-stopped
environment:
RABBITMQ_DEFAULT_USER: ${RABBITMQ_DEFAULT_USER}
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_DEFAULT_PASS}
volumes:
- rabbitmq_data:/var/lib/rabbitmq/
networks:
- dokploy-network
labels:
- traefik.tcp.routers.ingress.rule=HostSNI(`*`)
- traefik.tcp.routers.ingress.entrypoints=rabbitmq
- traefik.tcp.services.ingress.loadbalancer.server.port=5672
rabbitmq:
image: rabbitmq:4.0.4-management-alpine
restart: unless-stopped
environment:
RABBITMQ_DEFAULT_USER: ${RABBITMQ_DEFAULT_USER}
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_DEFAULT_PASS}
volumes:
- rabbitmq_data:/var/lib/rabbitmq/
networks:
- dokploy-network
labels:
- traefik.tcp.routers.ingress.rule=HostSNI(`*`)
- traefik.tcp.routers.ingress.entrypoints=rabbitmq
- traefik.tcp.services.ingress.loadbalancer.server.port=5672
Siumauricio
Siumauricio6mo ago
I think you need to add the provider in the traefik.yml and also expose the port from traefik Like to listen in that port 5672
ElPoulpo
ElPoulpoOP6mo ago
already have this into traefik.yml file
entryPoints:
web:
address: ':80'
websecure:
address: ':443'
http:
tls:
certResolver: letsencrypt
rabbitmq:
address: ':5672'
entryPoints:
web:
address: ':80'
websecure:
address: ':443'
http:
tls:
certResolver: letsencrypt
rabbitmq:
address: ':5672'
What should i do in provider section ? @Siumauricio How I can replicate what's done for database services but for custom service ? With external port settings or where I can find generated config for inspiration 🧐
ElPoulpo
ElPoulpoOP6mo ago
Or can I connect through internal network ? like for dbs
No description
ElPoulpo
ElPoulpoOP6mo ago
SOLUTION Internal naming the service as the dokploy service name and using it as host External just add a ports to map on the host machine 34567:5672
Tom
Tom2mo ago
Hello @ElPoulpo, i'm trying to setup rabbitmq but i failed, it seems to be working but cannot access the UI nor connect to it in with my backends. Can you share your compose and/or traefik settings ? I didn't understand your solution
ElPoulpo
ElPoulpoOP2mo ago
Hey @Tom
services:
<your-dokploy-service-id>: #replace by the service ID
image: rabbitmq:4.0.4-management-alpine
restart: unless-stopped
environment:
RABBITMQ_DEFAULT_USER: ${RABBITMQ_DEFAULT_USER}
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_DEFAULT_PASS}
RABBITMQ_DEFAULT_VHOST: your-vhost-name
volumes:
- rabbitmq_data:/var/lib/rabbitmq/
- rabbitmq_config:/etc/rabbitmq/
port: #This is only if you want to push and pull messages from outside your server, remove it if not needed
- <port>:5672 #here choose the <port> of your choice (for example 35456), it shouldn't be used by another service on your server.

volumes:
rabbitmq_data:
rabbitmq_config:
services:
<your-dokploy-service-id>: #replace by the service ID
image: rabbitmq:4.0.4-management-alpine
restart: unless-stopped
environment:
RABBITMQ_DEFAULT_USER: ${RABBITMQ_DEFAULT_USER}
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_DEFAULT_PASS}
RABBITMQ_DEFAULT_VHOST: your-vhost-name
volumes:
- rabbitmq_data:/var/lib/rabbitmq/
- rabbitmq_config:/etc/rabbitmq/
port: #This is only if you want to push and pull messages from outside your server, remove it if not needed
- <port>:5672 #here choose the <port> of your choice (for example 35456), it shouldn't be used by another service on your server.

volumes:
rabbitmq_data:
rabbitmq_config:
<your-dokploy-service-id> is not needed is you are not accessing rabbtimq:5672 from outside To access the console you have to setup a domain inside Domains tabs of your Dokploy service. And the console is on port 15672 no extra config needed in traefik or compose
Tom
Tom2mo ago
Thanks a lot I will try this !

Did you find this page helpful?