Vehicle_Road_Counter/mosquitto/config/mosquitto.conf

80 lines
3.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# =================================================================
# Mosquitto Broker 配置文件
# =================================================================
# ---- 持久化设置 ----
# 开启持久化将所有QoS>0的消息和会话状态保存到数据库文件
persistence true
# 持久化文件的存储位置 (注意:这是容器内的路径)
persistence_location /mosquitto/data/
# ---- 日志设置 ----
# 日志输出目的地 (file 表示输出到文件)
log_dest file /mosquitto/log/mosquitto.log
# 记录所有类型的日志
log_type all
# ---- 监听器设置 ----
# 监听所有网络接口的 1883 端口,用于标准的 MQTT 通信
listener 1883
# ---- 安全设置 (重要!) ----
# 允许匿名访问。在开发和测试阶段设为 true 很方便。
# 在生产环境中,强烈建议设为 false并配置用户/密码认证。
allow_anonymous true
# # =================================================================
# # Bridge Configuration to Cloud MQTT Broker
# # =================================================================
# # --- 1. 定义一个远程 Broker 连接 ---
# # "my_cloud_bridge" 是您给这个桥接起的名字,可以自定义
connection my_cloud_bridge
# # --- 2. 远程 Broker 的地址和端口 ---
# # 格式: address <host>:<port>
# # *** 请将这里的地址和端口替换为您真实的云端 Broker 信息 ***
address 192.168.0.54:1883
# # --- 3. 定义消息转发规则 ---
# # 关键字 "topic" 定义了转发规则
# # 格式: topic <pattern> <direction> <qos> <local_prefix> <remote_prefix>
# # 这条规则的意思是:
# # - <pattern>: "proxy/processed/#" 匹配所有以 "proxy/processed/" 开头的本地主题
# # - <direction>: "out" 表示将消息从本地 (edge) 发送出去 (out) 到云端 (cloud)
# # - <qos>: 1 使用 QoS 1 级别来转发
# # - local_prefix/remote_prefix: "" "" 表示本地和远程使用相同的主题名
topic proxy/processed/# out 1
# # 如果您想从云端接收命令到本地,可以再加一条 "in" 规则,例如:
topic commands/my-vehicle-road-counter-device-01/# in 1
# # --- 4. 客户端身份和认证 ---
# # 这个桥接在云端 Broker 看来,是一个普通的 MQTT 客户端
# # 所以我们需要为它指定一个客户端 ID
# # *** 请替换为您真实的客户端 ID ***
# remote_clientid my-edge-proxy-device-01
# # 如果云端需要用户名和密码认证
# # *** 请替换为您真实的用户名和密码 ***
# # remote_username device-user
# # remote_password a_very_secret_password
# # (如果您的云使用客户端证书认证,这里的配置会不同,需要使用 bridge_certfile 和 bridge_keyfile)
# # --- 5. 安全 (TLS/SSL) 设置 (对于连接云端至关重要) ---
# # 开启 TLS
# bridge_insecure false
# # 指定用于验证云端 Broker 服务器证书的 CA 证书文件
# # (注意:这是容器内的路径)
# # *** 请确保文件名与您放入 certs 目录的文件名一致 ***
# bridge_cafile /mosquitto/config/certs/AmazonRootCA1.pem
# # --- 6. 其他保持连接的设置 ---
# # 如果桥接断开,每 30 秒重试一次
# restart_timeout 30
# # 保持连接的心跳间隔
# keepalive_interval 60
# # 声明这是一个桥接连接
# cleansession false
# try_private false