mosquitto的acl规则及用户配置信息真让人头疼啊.折腾了半天才搞明白,随手记下来,省的下次又忘了.
首先mosquitto.conf中设置acl配置文件及用户配置文件:
password_file pwfile.example acl_file aclfile.example
pwfile.example为用户列表
aclfile.example为访问规则列表
在pwfile.example中需要以usernme/password格式添加相关用户
#发布信息用户 pub/pub #接收信息用户 sub/sub
然后在aclfile.example文件中配置用户可访问的topic信息
#用户信息 user pub #用户可访问的topic,这里为可读可写 topic mytopic/news #订阅用户可访问权限 user sub #这里为只读 topic read mytopic/news