最近把聊天室的程序从rocketchat换成了mattermost,这篇文章记录下配置过程。
其实我早就想把程序换成mattermost了,奈何之前的团队版本(白嫖版本)一直不支持权限控制功能,没有权限控制,任何人都可以删除消息,删除频道,修改配置,这样根本就不能用在生产环境。。
不知道这开发者是突然脑壳开了窍还是怎么的,终于肯把这个功能开放给白嫖版本了,那还说个锤子,rocketchat直接扔进垃圾桶!
早在几年前我已经写过一篇部署mattermost的文章了,不过隔了这么长时间,有很多配置步骤都失效了,所以也算重新记录一下吧。
安装docker和compose,注意这个compose目前还是建议安装1.x版本,2.x的版本有一些问题不好处理:
apt -y update apt -y install curl curl -fsSL https://get.docker.com -o get-docker.sh sh get-docker.sh curl -L https://github.com/docker/compose/releases/download/1.29.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose
新建项目目录,进入到项目的根目录:
mkdir -p /opt/mattermost && cd /opt/mattermost
新建一个compose:
nano docker-compose.yml
写入如下配置:
version: '3.5' services: postgres: container_name: postgres_mattermost image: postgres:13-alpine restart: unless-stopped security_opt: - no-new-privileges:true pids_limit: 100 read_only: true tmpfs: - /tmp - /var/run/postgresql env_file: - .env volumes: - ./volumes/db:/var/lib/postgresql/data mattermost: container_name: mattermost image: mattermost/mattermost-team-edition:6.5 restart: unless-stopped depends_on: - postgres security_opt: - no-new-privileges:true pids_limit: 200 read_only: false tmpfs: - /tmp env_file: - .env ports: - 127.0.0.1:8065:8065 volumes: - ./volumes/app/mattermost/config:/mattermost/config:rw - ./volumes/app/mattermost/data:/mattermost/data:rw - ./volumes/app/mattermost/logs:/mattermost/logs:rw - ./volumes/app/mattermost/plugins:/mattermost/plugins:rw - ./volumes/app/mattermost/client/plugins:/mattermost/client/plugins:rw - ./volumes/app/mattermost/bleve-indexes:/mattermost/bleve-indexes:rw
新建.env配置文件:
nano .env
设置你的数据库用户名以及密码替换掉imlala和password,另外用你的域名替换掉chat.example.com:
POSTGRES_DB=mattermost POSTGRES_USER=imlala POSTGRES_PASSWORD=password MM_SQLSETTINGS_DRIVERNAME=postgres MM_SQLSETTINGS_DATASOURCE=postgres://imlala:password@postgres:5432/mattermost?sslmode=disable&connect_timeout=10 MM_BLEVESETTINGS_INDEXDIR=/mattermost/bleve-indexes MM_SERVICESETTINGS_SITEURL=https://chat.example.com
创建项目需要用到的目录:
mkdir -p ./volumes/app/mattermost/{config,data,logs,plugins,client/plugins,bleve-indexes}
给予正确的目录权限:
chown -R 2000:2000 ./volumes/app/mattermost
启动即可:
docker-compose up -d
现在需要配置反向代理,首先安装nginx/certbot:
apt -y install nginx python3-certbot-nginx
新建一个nginx站点配置文件:
nano /etc/nginx/conf.d/mattermost.conf
写入如下配置:
upstream backend { server 127.0.0.1:8065; keepalive 32; } proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=mattermost_cache:10m max_size=3g inactive=120m use_temp_path=off; server { listen 80; server_name chat.example.com; location ~ /api/v[0-9]+/(users/)?websocket$ { proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; client_max_body_size 0; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Frame-Options SAMEORIGIN; proxy_buffers 256 16k; proxy_buffer_size 16k; client_body_timeout 60; send_timeout 300; lingering_timeout 5; proxy_connect_timeout 90; proxy_send_timeout 300; proxy_read_timeout 90s; proxy_pass http://backend; } location / { client_max_body_size 0; proxy_set_header Connection ""; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Frame-Options SAMEORIGIN; proxy_buffers 256 16k; proxy_buffer_size 16k; proxy_read_timeout 600s; proxy_cache mattermost_cache; proxy_cache_revalidate on; proxy_cache_min_uses 2; proxy_cache_use_stale timeout; proxy_cache_lock on; proxy_http_version 1.1; proxy_pass http://backend; } }
签发ssl证书:
certbot --nginx
登录后台,可以看到用户权限控制功能是可用的了:
LALA
我什么都不卖了,告辞!
最新评论
5211314
能不能教我 一点不会