OpenBSD Handbook

    Theme
    • Part I. Install & Configure
      • Introduction to OpenBSD
      • Installing OpenBSD
      • The X Window System
      • Networking on OpenBSD
      • System Configuration
      • OpenBSD Basics
      • Managing Software: Packages and Ports
    • Part II. Daily Operations
      • OpenBSD Desktop Environments
      • Multimedia
      • Printing
      • Linux Compatibility
      • Windows Compatibility
      • Games
    • Part III. System Administration
      • Virtualization
      • Storage and File Systems
      • Updating and Upgrading
      • Localization
      • The OpenBSD Boot Process
      • Security
    • Part IV. Networking & Daemons
      • Services
        • Database
          • MariaDB
          • PostgreSQL
          • Redis
          • memcached
        • Directory
          • YP (NIS)
          • LDAP
        • File
          • NFS
          • Samba
        • FTP Services
          • ftpd
          • ProFTPD
          • vsftpd
          • Pure-FTPd
          • TFTP
        • Mail
          • OpenSMTPD Mail Server
          • Dovecot IMAP and POP3 Server
          • Postfix
          • Exim
          • Rspamd
        • Name
          • Unbound DNS Resolver
          • NSD Authoritative DNS Server
          • BIND DNS Server
        • Networking
          • OpenBGPD
          • rad
          • DHCP on OpenBSD
          • slaacd
        • Web
          • Apache HTTP Server
          • nginx Web Server
          • OpenBSD httpd Web Server
          • relayd Reverse Proxy
        • Logging
          • syslogd
        • Monitoring
          • SNMP
        • Remote Access
          • Audit OpenSSH
          • OpenSSH Server
        • File Synchronization
          • rsync
        • Messaging
          • RabbitMQ Message Broker
        • Time
          • NTP Time Synchronization
        • Load Balancing
          • Build Redundant Load-Balanced Gateways
          • Load Balance Services with NAT or DSR
          • Build an HA HTTPS Load Balancer
      • PF
        • pfctl cheat sheet
        • PF Anchors
        • PF Filter Rules
        • PF Forwarding
        • PF Lists and Macros
        • PF Load Balancing
        • PF Logging
        • PF NAT
        • PF Options
        • PF Policies
        • PF Shortcuts
        • PF Tables
      • Advanced Networking
        • High Availability and State Replication
        • Multi-WAN and Policy-Based Routing
        • VPN and Cryptographic Tunneling
        • Classic and Lightweight Tunnels
        • IPv6 at Scale
        • QoS and Traffic Shaping
        • MPLS and Label Distribution
        • Network Services at Scale
        • Virtualization and Host Networking
        • Large-Scale L2 and L3 Design
        • Telemetry, Logging, and Flow Export
        • Hardening and Operational Safety
        • Reference Architectures
        • Troubleshooting Playbooks
      • Serial Communication
    • Part V. Miscellaneous
      • Virtualization Cheat Sheet
      • OpenBSD Cheatsheet
      • How-to Guides
        • Installation and First Boot
          • Complete the First 30 Minutes After Installation
          • Check Hardware Compatibility Before Installing
          • Bootstrap Wi-Fi Firmware Without Ethernet
          • Run OpenBSD as a Virtual Machine Guest
          • Install OpenBSD on a VPS or Cloud Server
          • Install OpenBSD with Full-Disk Encryption
          • Dual-Boot OpenBSD on a UEFI System
          • Automate OpenBSD Installation with Autoinstall and PXE
        • Desktops and Laptops
          • Set Up OpenBSD as a Laptop or Workstation
          • Configure Laptop Power Management
          • Troubleshoot Web Browsers on OpenBSD
          • Use Plan 9 Tools on OpenBSD
          • Build a Minimal Desktop with suckless Tools
          • Install Z shell (zsh)
        • Networking and Remote Access
          • Create an Administrator Account with doas and SSH Keys
          • Configure Secure Remote Access with OpenSSH
          • Use FIDO Security Keys with OpenSSH
          • Configure Wi-Fi Roaming and Wired Failover
          • Troubleshoot PF, NAT, and Routing
          • Route Multiple VLANs with PF
          • Configure a Road-Warrior WireGuard VPN
          • Route IPv6 Networks without NAT
          • Test OpenBGPD with Two Providers
          • Unlock an Internal Service with an SSH Key
          • Build a Simple Router and Firewall
        • Servers and Services
          • Set Up WordPress on OpenBSD
          • Build a Mail Server with OpenSMTPD, Dovecot, and Rspamd
        • Security, Maintenance and Recovery
          • Establish a Conservative Security Baseline
          • Recover Access and Reset the Root Password
          • Collect OpenBSD Diagnostic Evidence
          • Troubleshoot Package Installation and Update Failures
          • Schedule Recurring Maintenance
          • Monitor an OpenBSD System
          • Back Up and Restore an OpenBSD System
          • Configure softraid RAID1
          • Recover an OpenBSD System That Does Not Boot
        • Building, Automation and Virtual Machines
          • Manage OpenBSD with Ansible
          • Build Third-Party Software from Ports
          • Build OpenBSD from Source
          • Plan a Docker Workload Migration to OpenBSD
      • OpenBSD for Linux Users
      • OpenBSD for FreeBSD Users
      • OpenBSD for macOS Users
    • OpenBSD FAQ
    • OpenBSD Architectures
      • OpenBSD Package Search
        • Synopsis
        • Installation
        • Service Initialization
        • Configuration
        • User and Access Control
        • Web-Based Management Plugin
        • TLS Support
        • Firewall Configuration
        • Service Management
          • Inspecting Connection Protocols
        • Logging

        RabbitMQ Message Broker

        Synopsis #

        RabbitMQ is a message broker that implements the AMQP (Advanced Message Queuing Protocol). It is used to decouple services and distribute tasks using queues, topics, and publish-subscribe mechanisms.

        RabbitMQ supports persistent queues, acknowledgements, clustering, TLS encryption, and various plugins including web-based management.

        RabbitMQ is available on OpenBSD via the packages system. It runs on top of the Erlang runtime and communicates over TCP (AMQP by default on port 5672, and optionally HTTPS on port 15671 for management).

        Installation #

        Install both RabbitMQ and its Erlang runtime dependencies:

        doas pkg_add rabbitmq
        

        This installs:

        • rabbitmq-server: the main daemon
        • rabbitmqctl: administrative CLI
        • rabbitmq-plugins: plugin management utility
        • Default config directory: /etc/rabbitmq/

        RabbitMQ will refuse to run without a writable data directory.

        Service Initialization #

        The RabbitMQ service must be initialized before starting:

        doas install -d -o _rabbitmq -g _rabbitmq /var/rabbitmq
        

        Enable and start the service:

        doas rcctl enable rabbitmq
        doas rcctl start rabbitmq
        

        Before using CLI tools for the first time, wait for the broker to create its private Erlang cookie. Running a CLI tool as root too early can create a cookie that _rabbitmq cannot read:

        doas sh <<'ROOT'
        set -eu
        cookie=/var/rabbitmq/.erlang.cookie
        uid=$(id -u _rabbitmq)
        n=0
        while :; do
         if test -f "$cookie" && test ! -L "$cookie" &&
            test "$(stat -f %l "$cookie")" = 1 &&
            test "$(stat -f %u "$cookie")" = "$uid" &&
            { test "$(stat -f %Lp "$cookie")" = 400 || test "$(stat -f %Lp "$cookie")" = 600; } &&
            test "$(stat -f %z "$cookie")" -gt 0; then break; fi
         n=$((n+1)); test "$n" -le 60; sleep 1
        done
        rabbitmqctl -t 60 await_startup
        rabbitmqctl status
        ROOT
        

        If /var/rabbitmq/.erlang.cookie is root-owned, stop the service, set its owner to _rabbitmq:_rabbitmq and mode to 0400, then restart. Preserve the cookie contents and keep them private.

        See the RabbitMQ CLI shared-secret seeding guidance for the first-start race.

        By default, the daemon listens on:

        • TCP port 5672 (AMQP)
        • TCP port 25672 (Erlang distribution for clustering and administrative CLI communication)

        Configuration #

        RabbitMQ uses a directory-based config under /etc/rabbitmq/.

        There are two main files:

        • /etc/rabbitmq/rabbitmq-env.conf: shell environment overrides
        • /etc/rabbitmq/rabbitmq.conf: main configuration file (in INI-style format)

        Example /etc/rabbitmq/rabbitmq.conf:

        # Preserve the default guest loopback restriction
        
        # Default listener
        listeners.tcp.default = 127.0.0.1:5672
        
        # Enable TLS
        # listeners.ssl.default = 0.0.0.0:5671
        # ssl_options.certfile = /etc/ssl/rabbitmq/server.crt
        # ssl_options.keyfile = /etc/ssl/rabbitmq/server.key
        # ssl_options.cacertfile = /etc/ssl/rabbitmq/ca.crt
        

        Restart RabbitMQ after configuration changes:

        doas rcctl restart rabbitmq
        

        User and Access Control #

        To create a new user and virtual host:

        doas rabbitmqctl add_user myuser secretpass
        doas rabbitmqctl add_vhost myvhost
        doas rabbitmqctl set_permissions -p myvhost myuser ".*" ".*" ".*"
        

        Disable the default guest user for security:

        doas rabbitmqctl delete_user guest
        

        List users and vhosts:

        doas rabbitmqctl list_users
        doas rabbitmqctl list_vhosts
        

        Web-Based Management Plugin #

        To enable the RabbitMQ management interface:

        doas rabbitmq-plugins enable rabbitmq_management
        doas rcctl restart rabbitmq
        

        This exposes:

        • Port 15672: web UI (HTTP)
        • Port 15671: web UI (HTTPS, if TLS is configured)

        Access it at http://localhost:15672 using a user with an appropriate management tag and permissions.

        Create an admin user:

        doas rabbitmqctl add_user adminuser strongpass
        doas rabbitmqctl set_user_tags adminuser administrator
        

        Management HTTPS requires separate management.ssl settings; AMQP TLS below does not enable HTTPS on port 15671. Restrict the management listener to the administration network or loopback.

        TLS Support #

        To enable TLS, add to /etc/rabbitmq/rabbitmq.conf:

        listeners.ssl.default = 0.0.0.0:5671
        ssl_options.certfile = /etc/ssl/rabbitmq/server.crt
        ssl_options.keyfile = /etc/ssl/rabbitmq/server.key
        ssl_options.cacertfile = /etc/ssl/rabbitmq/ca.crt
        ssl_options.verify = verify_peer
        ssl_options.fail_if_no_peer_cert = true
        

        Ensure correct permissions:

        doas sh -c 'chown _rabbitmq:_rabbitmq /etc/ssl/rabbitmq/*'
        doas sh -c 'chmod 640 /etc/ssl/rabbitmq/*'
        

        Then restart:

        doas rcctl restart rabbitmq
        

        Firewall Configuration #

        If running outside localhost, allow ports through pf.conf:

        int_if = "em1"
        table <trusted_nets> { 192.0.2.0/24 }
        pass in on $int_if inet proto tcp from <trusted_nets> to ($int_if) port { 5672 5671 15672 }
        

        Avoid exposing RabbitMQ to untrusted networks unless TLS is enabled.

        Service Management #

        Standard service control:

        doas rcctl enable rabbitmq
        doas rcctl start rabbitmq
        doas rcctl check rabbitmq
        doas rcctl restart rabbitmq
        

        Check runtime info:

        doas rabbitmqctl status
        doas rabbitmqctl list_queues
        doas rabbitmqctl list_connections
        

        Inspecting Connection Protocols #

        The list_connections command accepts connection fields as positional arguments. The output columns follow the same order as the arguments. To display only the negotiated AMQP protocol version:

        doas rabbitmqctl list_connections protocol
        

        For a more useful connection inventory, include the connection name, authenticated user, client address, server listener, protocol, TLS state, and connection state:

        doas rabbitmqctl list_connections name user peer_host peer_port port protocol ssl state
        

        The protocol field reports {0,9,1} for AMQP 0-9-1 and {0,8,0} for AMQP 0-8. RabbitMQ treats an AMQP 0-9 request as AMQP 0-9-1. The port field is the server-side listener port. The peer_host and peer_port fields identify the client endpoint.

        The ssl field reports whether TLS protects the connection. Add ssl_protocol when the negotiated TLS version is also required:

        doas rabbitmqctl list_connections name protocol ssl ssl_protocol
        

        OpenBSD 8.0 packages RabbitMQ 4.3.6, where AMQP 1.0 support is built in. Use rabbitmqctl list_amqp10_connections for AMQP 1.0 connections; no AMQP 1.0 plugin activation is needed.

        Logging #

        RabbitMQ logs are written to:

        /var/log/rabbitmq/
        

        Use tail -f to follow log output:

        doas tail -f /var/log/rabbitmq/rabbit@localhost.log
        
        Report a bug
        • Synopsis
        • Installation
        • Service Initialization
        • Configuration
        • User and Access Control
        • Web-Based Management Plugin
        • TLS Support
        • Firewall Configuration
        • Service Management
          • Inspecting Connection Protocols
        • Logging