Configuration
Overview
RabbitMQ comes with default built-in settings. Those can be entirely sufficient in some environment (e.g. development and QA). For all other cases, as well as production deployment tuning, there is a way to configure many things in the broker as well as plugins.
This guide covers a number of topics related to configuration:
- Different ways in which various settings of the server and plugins are configured
- Configuration file(s): primary rabbitmq.conf or a directory of .conf files, and optional advanced.config
- Default configuration file location(s) on various platforms
- Configuration troubleshooting: how to find config file location and inspect and verify effective configuration
- Environment variable interpolation in
rabbitmq.conf
- Environment variables used by RabbitMQ nodes
- Operating system (kernel) limits
- Available core server settings
- Available environment variables
- How to encrypt sensitive configuration values
and more.
Since configuration affects many areas of the system, including plugins, individual documentation guides dive deeper into what can be configured. Runtime Tuning is a companion to this guide that focuses on the configurable parameters in the runtime. Deployment Guidelines is a related guide that outlines what settings will likely need tuning in most production environments.
Means of Configuration
A RabbitMQ node can be configured using a number of mechanisms responsible for different areas:
Mechanism | Description |
Contains server and plugin settings for TCP listeners and other networking-related settings, TLS, resource constraints (alarms), authentication and authorisation backends, message store settings, and more. | |
Used to define node name, file and directory locations, runtime flags taken from the shell, or set in
the environment configuration file, | |
When internal authentication/authorisation backend is used,
| |
| |
| |
| |
defines cluster-wide settings which can change at run time as well as settings that are convenient to configure for groups of queues (exchanges, etc) such as including optional queue arguments. | |
Control lower-level aspects of the system: memory allocation settings, inter-node communication buffer size, runtime scheduler settings and more. | |
Control process limits enforced by the kernel: max open file handle limit, max number of processes and kernel threads, max resident set size and so on. |
Most settings are configured using the first two methods. This guide, therefore, focuses on them.
Configuration File(s)
Introduction
While some settings in RabbitMQ can be tuned using environment variables,
most are configured using a main configuration file named rabbitmq.conf
.
This includes configuration for the core server as well as plugins. An additional configuration file can be used to configure settings that cannot be expressed in the main file's configuration format. This is covered in more details below.
The sections below cover the syntax and location of both files, where to find examples, and more.
Config File Locations
Default config file locations vary between operating systems and package types.
This topic is covered in more detail in the rest of this guide.
When in doubt about RabbitMQ config file location, consult the log file and/or management UI as explained in the following section.
How to Find Config File Location
The active configuration file can be verified by inspecting the RabbitMQ log file. It will show up in the log file at the top, along with the other broker boot log entries. For example:
node : rabbit@example
home dir : /var/lib/rabbitmq
config file(s) : /etc/rabbitmq/advanced.config
: /etc/rabbitmq/rabbitmq.conf
If the configuration file cannot be found or read by RabbitMQ, the log entry will say so:
node : rabbit@example
home dir : /var/lib/rabbitmq
config file(s) : /var/lib/rabbitmq/hare.conf (not found)
Alternatively, the location of configuration files used by a local node, use the rabbitmq-diagnostics status command:
# displays key
rabbitmq-diagnostics status
and look for the Config files
section that would look like this:
Config files
* /etc/rabbitmq/advanced.config
* /etc/rabbitmq/rabbitmq.conf
To inspect the locations of a specific node, including nodes running remotely, use the -n
(short for --node
) switch:
rabbitmq-diagnostics status -n [node name]
Finally, config file location can be found in the management UI, together with other details about nodes.
When troubleshooting configuration settings, it is very useful to verify that the config file path is correct, exists and can be loaded (e.g. the file is readable) before verifying effective node configuration. Together, these steps help quickly narrow down most common misconfiguration problems.
The Modern and Old Config File Formats
All supported RabbitMQ versions use an ini-like, sysctl configuration file format
for the main configuration file. The file is typically named rabbitmq.conf
.
The new config format is much simpler, easier for humans to read and machines to generate. It is also relatively limited compared to the classic config format used prior to RabbitMQ 3.7.0. For example, when configuring LDAP support, it may be necessary to use deeply nested data structures to express desired configuration.
To accommodate this need, modern RabbitMQ versions allow for both formats to be used at the same time
in separate files: rabbitmq.conf
uses the new style format and is recommended for most settings,
and advanced.config
covers more advanced settings that the ini-style configuration
cannot express. This is covered in more detail in the following sections.
Configuration File | Format Used | Purpose |
rabbitmq.conf | New style format (sysctl or ini-like) | Primary configuration file with a |
advanced.config | Classic (Erlang terms) | A limited number of settings that cannot be expressed in the new style configuration format, such as LDAP queries. Only should be used when necessary. |
rabbitmq-env.conf (rabbitmq-env.conf.bat on Windows) | Environment variable pairs | Used to set environment variables relevant to RabbitMQ in one place. |
Compare this examplary rabbitmq.conf
file
# A new style format snippet. This format is used by rabbitmq.conf files.
ssl_options.cacertfile = /path/to/ca_certificate.pem
ssl_options.certfile = /path/to/server_certificate.pem
ssl_options.keyfile = /path/to/server_key.pem
ssl_options.verify = verify_peer
ssl_options.fail_if_no_peer_cert = true
to
%% A classic format snippet, now used by advanced.config files.
[
{rabbit, [{ssl_options, [{cacertfile, "/path/to/ca_certificate.pem"},
{certfile, "/path/to/server_certificate.pem"},
{keyfile, "/path/to/server_key.pem"},
{verify, verify_peer},
{fail_if_no_peer_cert, true}]}]}
].
The Main Configuration File, rabbitmq.conf
The configuration file rabbitmq.conf
allows the RabbitMQ server and plugins to be configured.
The file uses the sysctl format,
unlike advanced.config
and the original rabbitmq.config
(both use the Erlang terms format).
The syntax can be briefly explained in 3 lines:
- One setting uses one line
- Lines are structured
Key = Value
- Any line starting with a
#
character is a comment - Values that contain the
#
character, such as generated strings, generated passwords, encrypted values, and so on, can be escaped with single quotes like so:'efd3!53a9@92#a08_d_6d'
A minimalistic example configuration file follows:
# this is a comment
listeners.tcp.default = 5673
The above example is equivalent to the following classic config format:
%% this is a comment
[
{rabbit, [
{tcp_listeners, [5673]}
]
}
].
This example will alter the port RabbitMQ listens on for AMQP 0-9-1 and AMQP 1.0 client connections from 5672 to 5673.
The RabbitMQ server source repository contains an example rabbitmq.conf file
named rabbitmq.conf.example
. It contains examples of
most of the configuration items you might want to set (with some very obscure ones omitted), along with
documentation for those settings.
Documentation guides such as Networking, TLS, or Access Control contain many examples in relevant formats.
Note that this configuration file is not to be confused with the environment variable configuration files, rabbitmq-env.conf and rabbitmq-env-conf.bat.
To override the main RabbitMQ config file location, use the RABBITMQ_CONFIG_FILE
(or RABBITMQ_CONFIG_FILES
to use a conf.d
-style directory of sorted files) environment variables.
Use .conf
as file extension for the new style config format, e.g. /etc/rabbitmq/rabbitmq.conf
or
/data/configuration/rabbitmq/rabbitmq.conf
Value Escaping
Lines that use escaped values must not contain any (in particularly trailing) comments. Please any comments necessary above the line instead.
Values that contain the #
character, usually machine-generated, can be escaped with single quotes:
# escaping is not necessary here but may be a good idea for generated
# values
default_user = '7f11ddc4f1900a233964'
# escaping is important here as without it,
# the # character and everything that follows it would be
# considered a comment
default_pass = 'efd3!53a9@92#a08_d_6d'