禁用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