docker-compose 部署 emqx

创建数据目录

# mkdir data logs etc

数据目录授权

# chown 1000 data/ logs/ etc/

docker-compose.yaml

version: '3'

services:
  emqx1:
    image: emqx:5.3.0
    container_name: emqx
    restart: always
    environment:
      - TZ=Asia/Shanghai
    healthcheck:
      test: ["CMD", "/opt/emqx/bin/emqx_ctl", "status"]
      interval: 5s
      timeout: 25s
      retries: 5
    networks:
      emqx-bridge:
        aliases:
        - node1.emqx.io
    ports:
      - 1883:1883
      - 8083:8083
      - 8084:8084
      - 8883:8883
      - 18083:18083 
    volumes:
      - ./logs:/opt/emqx/log
      - ./data:/opt/emqx/data


networks:
  emqx-bridge:
    driver: bridge

运行 emqx

# docker-compose up -d

Nginx

server {
    listen        80;
    server_name xxxxxx ;
    rewrite ^(.*)$ https://${server_name}$1 permanent;

}

server {

    listen       443 ssl http2;
    server_name xxxxxx;
    access_log logs/emqx_access.log json;
    error_log logs/emqx_error.log;

    index  index.html index.htm index.php;


    location / {
     proxy_pass http://172.16.1.28:18083;
   }

     #从腾讯云获取到的第一个文件的全路径
     ssl_certificate xxxxxx;
     #从腾讯云获取到的第二个文件的全路径
     ssl_certificate_key xxxxxx;
     ssl_session_timeout 5m;
     ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
     ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
     ssl_prefer_server_ciphers on;

}

Dashboard

默认用户名: admin
默认密码:   public

设置 emqx

emqx 日志设置

关闭控制台日志

开启文件日志

注意事项

执行 docker-compose down 命令后,重启emqx服务会重置以前设置的配置信息,需要重新走初始化流程。例如:登录需要初始密码 public,需要重修改密码。
posted @ 2023-11-01 16:25  小吉猫  阅读(1458)  评论(0编辑  收藏  举报