Mosquitto conf 限制与代理的未授权连接

Mosquitto conf restricting unauthorized connection to broker

我已经使用 mosquitto 2.0.11 图像创建了一个 Mosquitto docker 图像,我有一个 Node-RED 实例,它也被部署为 docker,现在我想限制使用 mosquitto 的用户可以连接到经纪人。 一种方法是创建用户名和密码,并只允许具有有效 username/password 的应用程序连接到 Mosquitto 代理,但我正在寻找 mosquitto.conf 文件中的一种方法,我们可以在其中提及主机名应用程序(在本例中为 Node-RED),并且只允许那些应用程序连接到代理而无需进行身份验证。

现在我的 conf 文件如下所示

listener 1883
allow_anonymous true

我想从我的 conf 文件中删除 allow_anonymous true 并提及我想连接到 mosquitto 代理的应用程序的主机名。有办法吗?

谢谢。

目前没有内置的方法来根据 mosquitto 内置的源 IP 地址进行访问控制,通常的方法是为每个想要连接的客户端使用 username/password。

Mosquitto 提供了一个内置的基于文本文件的系统来提供 username/passwords 和 ACL。它还提供了一种使用 MQTT 消息设置动态 user/acl 创建的方法。

记录了动态安全设置 here. Details of the password file and acl file are in the mosquitto.conf man page

如果您想进行基于 IP 地址的访问控制,那么您可能需要查看 iptables 和 inetd hosts.allow/hosts.deny