mqtt password

This commit is contained in:
jeremygan2021
2025-11-16 18:20:08 +08:00
parent 6dc4d0699a
commit 5c36736141
5 changed files with 30 additions and 6 deletions

6
.env
View File

@@ -4,10 +4,10 @@
DATABASE_URL=postgresql://luna:123luna@121.43.104.161:6432/luna
# MQTT配置
MQTT_BROKER_HOST=localhost
MQTT_BROKER_HOST=luna-mqtt
MQTT_BROKER_PORT=1883
# MQTT_USERNAME=
# MQTT_PASSWORD=
MQTT_USERNAME=luna2025
MQTT_PASSWORD=123luna2021
# 应用配置
APP_NAME=墨水屏桌面屏幕系统

View File

@@ -6,8 +6,8 @@ DATABASE_URL=postgresql://luna:123luna@121.43.104.161:6432/luna
# MQTT配置 - 使用Docker内部服务名
MQTT_BROKER_HOST=luna-mqtt
MQTT_BROKER_PORT=1883
# MQTT_USERNAME=
# MQTT_PASSWORD=
MQTT_USERNAME=luna2025
MQTT_PASSWORD=123luna2021
# 应用配置
APP_NAME=墨水屏桌面屏幕系统
@@ -23,7 +23,7 @@ INK_WIDTH=400
INK_HEIGHT=300
# 安全配置
SECRET_KEY=your-secret-key-change-in-production
SECRET_KEY=123quant-speed
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30

View File

@@ -25,8 +25,10 @@ services:
- "1883:1883"
- "9001:9001"
volumes:
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf
- mosquitto_data:/mosquitto/data
- mosquitto_logs:/mosquitto/log
- mosquitto_config:/mosquitto/config
restart: unless-stopped
networks:
- luna-network
@@ -35,6 +37,7 @@ services:
volumes:
mosquitto_data:
mosquitto_logs:
mosquitto_config:
# 网络
networks:

10
mosquitto.conf Normal file
View File

@@ -0,0 +1,10 @@
# Mosquitto配置文件
# 监听端口
listener 1883
# 允许匿名连接默认为true我们将设置为false以要求认证
allow_anonymous false
# 密码文件
password_file /mosquitto/config/passwd

11
setup_mqtt_auth.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
# 创建MQTT密码文件
docker exec luna-mqtt mosquitto_passwd -c -b /mosquitto/config/passwd luna2025 123luna2021
# 重启MQTT服务以应用新的认证配置
docker restart luna-mqtt
echo "MQTT用户名和密码已配置完成"
echo "用户名: luna2025"
echo "密码: 123luna2021"