如何禁用 RabbitMQ 默认 TCP 侦听端口 - 5672



我已经用新的端口号配置了RabbitMQ rabbitmq.config文件,即使用SSL的5671。

现在我想禁用默认端口,即 5672。

配置文件如下:-

[
  {rabbit, [
     {ssl_listeners, [5671]},
     {ssl_options, [{cacertfile,"/ay/app/xxx/softwares/rabbitmq_server-3.1.1/etc/ssl/cacert.pem"},
                    {certfile,"/ay/app/xxx/softwares/rabbitmq_server-3.1.1/etc/ssl/cert.pem"},
                    {keyfile,"/ay/app/xxx/softwares/rabbitmq_server-3.1.1/etc/ssl/key.pem"},
                    {verify,verify_peer},
                    {fail_if_no_peer_cert,false},
                   {ciphers,[{dhe_rsa,aes_256_cbc,sha},
 {dhe_dss,aes_256_cbc,sha},
 {rsa,aes_256_cbc,sha}]}
                    ]
    }
   ]}
].
现在它在端口 5671 和 5672

上工作。但我需要禁用端口 5672。提出一些意见或建议。

提前谢谢。

要禁用 标准 RabbitMQ 5672 端口,请将{tcp_listeners, []}添加到您的 rabbitmq.conf:

[
  {rabbit, [
     {tcp_listeners, []},
     {ssl_listeners, [5671]},
     {ssl_options, [{cacertfile,"/ay/app/xxx/softwares/rabbitmq_server-3.1.1/etc/ssl/cacert.pem"},
                    {certfile,"/ay/app/xxx/softwares/rabbitmq_server-3.1.1/etc/ssl/cert.pem"},
                    {keyfile,"/ay/app/xxx/softwares/rabbitmq_server-3.1.1/etc/ssl/key.pem"},
                    {verify,verify_peer},
                    {fail_if_no_peer_cert,false},
                   {ciphers,[{dhe_rsa,aes_256_cbc,sha},
 {dhe_dss,aes_256_cbc,sha},
 {rsa,aes_256_cbc,sha}]}
                    ]
    }
   ]}
].

它适用于 RabbitMQ 3.1.5

似乎要禁用使用新文件格式的非 SSL 侦听,您可以执行以下操作:

listeners.tcp  = none

这与其他 3.7 答案具有相同的效果,但无需在 advanced.config 中执行此操作。

以下是使用 RabbitMQ 3.7 中引入的新配置文件格式的方法:

  1. 在 rabbitmq.conf 中设置 SSL 侦听器:

    listeners.ssl.1 = 5671
    ssl_options.cacertfile = /path/to/testca/cacert.pem
    ssl_options.certfile = /path/to/server/cert.pem
    ssl_options.keyfile = /path/to/server/key.pem
    ssl_options.verify = verify_peer
    ssl_options.fail_if_no_peer_cert = false
    
  2. 在 advanced.config 中禁用非 SSL 侦听器:

    [
     {rabbit,
      [{tcp_listeners, []}
      ]}
    ].
    

最新更新