My goal is to set rabbitmq with ssl support, which was achieved previously using below rabbitmq.config
file, which resides in host's /etc/rabbitmq
path.
Now I want to be able to configure other rabbitmq user and password than defaults guest
guest
.
I'm using rabbitmq docker image with following docker-compose configuration:
version: '2'
services:
rabbitmq:
build: ./rabbitmq
ports:
- "8181:8181"
expose:
- "15672"
- "8181"
volumes:
- /etc/rabbitmq:/etc/rabbitmq
environment:
RABBITMQ_DEFAULT_USER: user123
RABBITMQ_DEFAULT_PASS: 1234
Rabbitmq config :
[{rabbit,
[
{loopback_users, []},
{heartbeat,0},
{ssl_listeners, [8181]},
{ssl_options, [{cacertfile, "/etc/rabbitmq/ca/cacert.pem"},
{certfile, "/etc/rabbitmq/server/cert.pem"},
{keyfile, "/etc/rabbitmq/server/key.pem"},
{verify,verify_none},
{fail_if_no_peer_cert,false}]}
]}
].
Rabbitmq dockerfile :
from rabbitmq:management
#and some certificate generating logic
I noticed that once upon adding environment
section, current rabbitmq.config
file is overriden with auto generated configuration possibly by docker-entrypoint.sh file .
For building configuration using the certs I found environment variables that can do this (look here ). However didn't found any reference for defining ssl_listeners
section with its port, as seen in below rabbitmq.config
My question is : how can I create the exact configuration as mentioned below using env variables OR how can I remain with mine rabbitmq.config
defining rabbitmq with new user and password in some dynamic way (maybe templating the config file)?
Try this
version: '2'
services:
rabbitmq:
build: ./rabbitmq
ports:
- "8181:8181"
expose:
- "15672"
- "8181"
volumes:
- /etc/rabbitmq:/etc/rabbitmq
command: rabbitmq-server
entrypoint: ""
environment:
RABBITMQ_DEFAULT_USER: user123
RABBITMQ_DEFAULT_PASS: 1234
This will override the docker-entrpoint
and just run the rabbitmq server. Now the ./docker-entrypoint.sh
sets certain environment variables also. Which may be needed in your case. So to make sure you have everything needed
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.