前言:由于某些众所周知的原因,端对端聊天在某国是被禁止的,但是可以通过自己搭建的方式,实现与朋友的端对端聊天。
这种方法的优点在于其代码是开源的,而且数据也存放在自己的服务器上,相比市面的端对端聊天软件还是比较安全的。
下面就以Ubuntu为例,聊聊怎么以Docker的形式搭建端加密的聊天平台Rocket.Chat。
1. 安装Docker和Docker Compose:
1.1 码头工人
引用
curl -fsSL https://test.docker.com -o test-docker.sh
sudo sh test-docker.sh
1.2 码头工人撰写
引用
sudo curl -L "https://github.com/docker/compose/releases/download/v2.2.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
2. 在服务器的root路径下新建一个名为rocketchat的文件夹:
引用
mkdir /root/rocketchat
cd /root/rocketchat
3. 去Rocket.Chat的Github
https://github.com/RocketChat 下载
docker-compose.yml 和
env.example文件,并上传到/root/rocketchat路径下。嫌懒的可以直接复制下面的代码:
3.1 docker-compose.yml
- volumes:
- mongodb_data: { driver: local }
-
- services:
- rocketchat:
- image: registry.rocket.chat/rocketchat/rocket.chat:${RELEASE:-latest}
- restart: always
- labels:
- traefik.enable: "true"
- traefik.ht@Gue^33D-9#[email][email protected][/email]: Host(`${DOMAIN:-}`)
- traefik.ht@Gue^33D-9#[email][email protected][/email]: "true"
- traefik.ht@Gue^33D-9#[email][email protected][/email]ypoints: https
- traefik.ht@Gue^33D-9#[email][email protected][/email]resolver: le
- environment:
- MONGO_URL: "${MONGO_URL:-\
- mongodb://${MONGODB_ADVERTISED_HOSTNAME:-mongodb}:${MONGODB_INITIAL_PRIMARY_PORT_NUMBER:-27017}/\
- ${MONGODB_DATABASE:-rocketchat}?replicaSet=${MONGODB_REPLICA_SET_NAME:-rs0}}"
- MONGO_OPLOG_URL: "${MONGO_OPLOG_URL:\
- -mongodb://${MONGODB_ADVERTISED_HOSTNAME:-mongodb}:${MONGODB_INITIAL_PRIMARY_PORT_NUMBER:-27017}/\
- local?replicaSet=${MONGODB_REPLICA_SET_NAME:-rs0}}"
- ROOT_URL: ${ROOT_URL:-http://localhost:${HOST_PORT:-3000}}
- PORT: ${PORT:-3000}
- DEPLOY_METHOD: docker
- DEPLOY_PLATFORM: ${DEPLOY_PLATFORM:-}
- REG_TOKEN: ${REG_TOKEN:-}
- depends_on:
- - mongodb
- expose:
- - ${PORT:-3000}
- ports:
- - "${BIND_IP:-0.0.0.0}:${HOST_PORT:-3000}:${PORT:-3000}"
-
- mongodb:
- image: docker.io/bitnami/mongodb:${MONGODB_VERSION:-5.0}
- restart: always
- volumes:
- - mongodb_data:/bitnami/mongodb
- environment:
- MONGODB_REPLICA_SET_MODE: primary
- MONGODB_REPLICA_SET_NAME: ${MONGODB_REPLICA_SET_NAME:-rs0}
- MONGODB_PORT_NUMBER: ${MONGODB_PORT_NUMBER:-27017}
- MONGODB_INITIAL_PRIMARY_HOST: ${MONGODB_INITIAL_PRIMARY_HOST:-mongodb}
- MONGODB_INITIAL_PRIMARY_PORT_NUMBER: ${MONGODB_INITIAL_PRIMARY_PORT_NUMBER:-27017}
- MONGODB_ADVERTISED_HOSTNAME: ${MONGODB_ADVERTISED_HOSTNAME:-mongodb}
- MONGODB_ENABLE_JOURNAL: ${MONGODB_ENABLE_JOURNAL:-true}
- ALLOW_EMPTY_PASSWORD: ${ALLOW_EMPTY_PASSWORD:-yes}
3.2 环境示例
- ### Rocket.Chat configuration
-
- # Rocket.Chat version
- # see:- https://github.com/RocketChat/Rocket.Chat/releases
- #RELEASE=
- # MongoDB endpoint (include ?replicaSet= parameter)
- #MONGO_URL=
- # MongoDB endpoint to the local database
- #MONGO_OPLOG_URL=
- # IP to bind the process to
- #BIND_IP=
- # URL used to access your Rocket.Chat instance
- #ROOT_URL=
- # Port Rocket.Chat runs on (in-container)
- #PORT=
- # Port on the host to bind to
- #HOST_PORT=
-
- ### MongoDB configuration
- # MongoDB version/image tag
- #MONGODB_VERSION=
- # See:- https://hub.docker.com/r/bitnami/mongodb
-
- ### Traefik config (if enabled)
- # Traefik version/image tag
- #TRAEFIK_RELEASE=
- # Domain for https (change ROOT_URL & BIND_IP accordingly)
- #DOMAIN=
- # Email for certificate notifications
- #LETSENCRYPT_EMAIL=
3.3 修改环境示例:
引用
#PORT=
修改为
PORT=服务器公网IP或域名
4. 放行3000端口;
5. 运行Docker(下载文件需要一段时间):
引用
docker compose up -d
6. Docker运行后(实测还需要再等待一段时间),打开下面这个网址,注册管理员账户(第一次注册的默认为管理员)
引用
服务器公网IP或域名:3000
7. 然后就可以开心的玩耍了,如果嫌访问地址带端口有点麻烦,再做个反代就行了。
防水图:
赞(32)