Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

怎么配置账号密码 #445

Open
ascarl2010 opened this issue Jan 6, 2025 · 2 comments
Open

怎么配置账号密码 #445

ascarl2010 opened this issue Jan 6, 2025 · 2 comments

Comments

@ascarl2010
Copy link

ascarl2010 commented Jan 6, 2025

`/ # cat config.yaml 
# 监听器设置
listeners:
  - type: "tcp"
    id: "tcp1"
    address: ":1883"       # TCP 监听在 1883 端口
  - type: "ws"
    id: "ws1"
    address: ":1882"       # WebSocket 监听在 1882 端口
  - type: "sysinfo"
    id: "stats"
    address: ":1880"       # 系统信息监听在 1880 端口

# 钩子(Hooks)设置
hooks:
  auth:
    allow_all: false       # 禁用 allow_all,强制启用用户认证

# 额外选项
options:
  inline_client: true      # 启用内嵌客户端,用于测试发布和订阅

# 身份认证设置
auth:
  enable: true             # 是否启用认证
  users:                   # 定义账号密码列表
    - username: mqttuser1  # 用户名
      password: DK9203dfs382 # 密码
    - username: mqttuser2  # 第二个用户名
      password: DK9203dfs383 # 第二个密码

# 日志设置
log:
  level: info              # 日志级别:debug, info, warn, error
  file: /var/log/mochi-mqtt.log # 日志文件路径(可选)
`

然后docker运行
docker run -d -p 1883:1883 -p 1882:1882 -p 1880:1880 -v /opt/config.yaml:/config.yaml mochimqtt/server:latest

这样配置以后还是提示账号密码错误,是漏了什么吗

@ascarl2010
Copy link
Author

How to configure the account password

@werbenhu
Copy link
Member

werbenhu commented Jan 7, 2025

@ascarl2010 Take a look at config.yaml to check if the auth section in your configuration file is set up correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants