# RabbitMQ 启用 HTTP 后台认证

# 启动权限管理插件

rabbitmq-plugins enable rabbitmq_auth_backend_http
rabbitmq-plugins enable rabbitmq_auth_backend_cache
1
2

# 配置rabbitmq.conf

默认情况下 RabbitMQ 使用的默认配置,在该目录下面并没有配置文件,需要自己手动创建。

centos7的位置在/etc/rabbitmq/

vim /etc/rabbitmq/rabbitmq.conf
1

内容如下:

auth_backends.1 = cache
# 启用 cache 后,不需要直接指定 http 方式
# auth_backends.1 = http
auth_backends.2 = internal
# 缓存后端指定为 http
auth_cache.cached_backend = http
# 认证请求类型
auth_http.http_method   = post
# 认证和授权地址,官方提供了 Spring Boot 示例
# 根据需要配置下面地址
auth_http.user_path = http://localhost:8080/auth/user
auth_http.vhost_path = http://localhost:8080/auth/vhost
auth_http.resource_path = http://localhost:8080/auth/resource
auth_http.topic_path = http://localhost:8080/auth/topic
# 缓存时间,单位毫秒
auth_cache.cache_ttl = 60000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
auth_backends.1 = cache
auth_backends.2 = internal
auth_cache.cached_backend = http
auth_http.http_method   = post
auth_http.user_path = http://rabbitmq:9003/auth/user
auth_http.vhost_path = http://rabbitmq:9003/auth/vhost
auth_http.resource_path = http://rabbitmq:9003/auth/resource
auth_http.topic_path = http://rabbitmq:9003/auth/topic
auth_cache.cache_ttl = 60000
1
2
3
4
5
6
7
8
9

其中rabbitmq在host中设置了对应关系

# 重启

systemctl restart rabbitmq-server
1
上次更新时间: 2024年2月12日星期一晚上7点28分