禁用rabbitmq 5672埠

一、概述

5672是rabbitmq 默認TCP監聽埠,我已經給rabbitmq配置SSL,它使用新的埠號5671。

目前的SSL版rabbitmq配置文件/etc/rabbitmq/rabbitmq.config

完整內容如下:

[    {rabbit, [       {ssl_listeners, [5671]},       {ssl_options, [{cacertfile,"/etc/rabbitmq/cert/ca_certificate.pem"},                      {certfile,"/etc/rabbitmq/cert/client_certificate.pem"},                      {keyfile,"/etc/rabbitmq/cert/client_key.pem"},                      {verify,verify_peer},                      {fail_if_no_peer_cert,true}]}     ]}  ].

現在它在埠5671和5672上工作

二、關閉埠

修改配置文件

要禁用標準的RabbitMQ 5672埠,將{tcp_listeners,[]}添加到您的rabbitmq.conf中:

/etc/rabbitmq/rabbitmq.config 完整內容如下:

[    {rabbit, [       {tcp_listeners, []},       {ssl_listeners, [5671]},       {ssl_options, [{cacertfile,"/etc/rabbitmq/cert/ca_certificate.pem"},                      {certfile,"/etc/rabbitmq/cert/client_certificate.pem"},                      {keyfile,"/etc/rabbitmq/cert/client_key.pem"},                      {verify,verify_peer},                      {fail_if_no_peer_cert,true}]}     ]}  ].

它適用於RabbitMQ >=3.1.5,由於我的版本為3.8.2,所以是支援的。

重啟rabbitmq

/etc/init.d/rabbitmq-server restart

查看埠

命令行方式

# netstat -anpt|grep beam.smp  tcp        0      0 0.0.0.0:25672               0.0.0.0:*                   LISTEN      5459/beam.smp         tcp        0      0 0.0.0.0:15672               0.0.0.0:*                   LISTEN      5459/beam.smp         tcp        0      0 127.0.0.1:54963             127.0.0.1:4369              ESTABLISHED 5459/beam.smp         tcp        0      0 :::5671                     :::*                        LISTEN      5459/beam.smp

rabbitmq後台管理頁面

登錄到rabbitmq後台,展開埠內容。

 可以發現沒有5672了。

本文參考鏈接:

http://www.voidcn.com/article/p-udmrsctc-btu.html