0
点赞
收藏
分享

微信扫一扫

Docker eclipse-mosquitto配置SSL

1.   从DockerHub下载eclipse-mosquitto

选择需要安装的版本,执行docker pull eclipse-mosquitto:版本

2.      启动容器

Docker run -itd --name="容器名称" -p 主机端口:容器端口 -p 9001:9001 镜像id

3.      将ssl证书复制到容器中

docker cp [OPTIONS] 源文件路径容器名称:目标路径

4.      进入容器修改eclipse-mosquitto配置文件

docker exec –it容器名称 /bin/sh

/mosquitto/config/mosquitto.conf

配置如下:

#是否允许匿名登录

allow_anonymous false

#使用mosquitto_passwd生成用户账号(touch /mosquitto/config/pwfile.conf & mosquitto_passwd -b /mosquitto/config/pwfile.conf admin admin123)

password_file /mosquitto/config/pwfile.conf

persistence_location /mosquitto/data

log_dest file /mosquitto/log/mosquitto.log

 

#mqtt协议

listener 1883

protocol mqtt

socket_domain ipv4

                 

# mqtt wss协议

listener 9001         

#证书位置          

certfile /mosquitto/ssl/server.crt

keyfile /mosquitto/ssl/server.key              

protocol websockets              

举报

相关推荐

0 条评论