Tổng Hợp VPS

Mattermost self-host trên VPS: Slack alternative cho team VN

Tự host Mattermost trên VPS Ubuntu: thay Slack, tiết kiệm 90% chi phí team VN. Setup Docker, Postgres, OAuth, mobile app, bot, plugin Jira/GitHub.

Thanh Nguyễn Cập nhật Đăng 7 phút đọc 7 khối lệnh

Mattermost self-host trên VPS: Slack alternative cho team VN
Mục lục bài viết
  1. 1. Mattermost vs Slack vs Rocket.Chat
  2. 2. Yêu cầu VPS
  3. 3. Cài qua Docker Compose
  4. 4. Cấu hình System Console
  5. 5. Cấu hình OAuth Google/GitLab
  6. 6. Mobile push notification
  7. 7. Plugin GitHub/Jira integration
  8. 8. Bot và webhook
  9. 9. Search và performance
  10. 10. Backup hằng đêm
  11. 11. Migrate từ Slack
  12. 12. Monitor và logs
  13. FAQ

Slack đã thành xương sống team chat 2026 nhưng pricing 7.25$/user/tháng cho 90+ ngày message giữ lại là gánh nặng cho startup VN. Team 30 người = 217$/tháng = 5.5tr VND. Mattermost open source thay thế đầy đủ tính năng, tự host VPS chỉ 250-500k/tháng. Bài này hướng dẫn full setup production-ready.

Mattermost dùng stack Go (backend) + React (web) + RN (mobile). Performance tốt, scale tới team 1000+ user trên VPS 16GB. Có Enterprise tier với SAML SSO, audit log nâng cao - team <50 user không cần. Team Edition free cover 95% nhu cầu.

Mục tiêu cuối bài: bạn có Mattermost chạy HTTPS trên domain riêng, user team login, mobile push notification hoạt động, plugin GitHub gắn vào dev channel, backup hằng ngày.

1. Mattermost vs Slack vs Rocket.Chat

Tính năngMattermostSlackRocket.Chat
LicenseMIT (Team Edition)Closed SaaSMIT
Pricing 30 user250-500k VPS217$/tháng250-500k VPS
PerformanceGo - rất nhanhSaaSNode.js - chậm hơn
Mobile appCó (iOS/Android)CóCó
Channel limitKhông10000+Không
Message historyKhông giới hạn90 ngày freeKhông giới hạn
Plugin ecosystem50+2000+100+

Mattermost nhỉnh Rocket.Chat ở performance (Go nhanh hơn Node.js 2-3x), UI giống Slack hơn (team chuyển sang dễ). Rocket.Chat hỗ trợ video call WebRTC built-in tốt hơn. Cá nhân mình recommend Mattermost cho team dev VN.

2. Yêu cầu VPS

  • RAM: 2GB cho 50 user, 4GB cho 200 user, 8GB cho 500+.
  • vCPU: 2-4.
  • SSD: 40-100GB (file upload chiếm phần lớn).
  • Ubuntu 22/24 LTS.
  • Domain: chat.your-domain.com.
  • Network: 200Mbps đủ cho team 100 user concurrent.

3. Cài qua Docker Compose

Terminal3. Cài qua Docker Composebash
curl -fsSL https://get.docker.com | shmkdir -p /opt/mattermost/{postgres,mm-data,mm-config,mm-logs,mm-plugins}cd /opt/mattermost
Terminal3. Cài qua Docker Composebash
# .envPOSTGRES_PASSWORD=$(openssl rand -base64 32 | tr -d /=+)MM_USERNAME=mmuserMM_DBNAME=mattermost
File cấu hình3. Cài qua Docker Composeyaml
# docker-compose.ymlservices:  postgres:    image: postgres:16-alpine    restart: unless-stopped    environment:      POSTGRES_DB: $MM_DBNAME      POSTGRES_USER: $MM_USERNAME      POSTGRES_PASSWORD: $POSTGRES_PASSWORD    volumes:      - ./postgres:/var/lib/postgresql/data   mattermost:    image: mattermost/mattermost-team-edition:latest    restart: unless-stopped    depends_on: [postgres]    environment:      MM_SQLSETTINGS_DRIVERNAME: postgres      MM_SQLSETTINGS_DATASOURCE: "postgres://${MM_USERNAME}:${POSTGRES_PASSWORD}@postgres:5432/${MM_DBNAME}?sslmode=disable"      MM_BLEVESETTINGS_INDEXDIR: /mattermost/bleve-indexes      MM_SERVICESETTINGS_SITEURL: https://chat.your-domain.com    volumes:      - ./mm-data:/mattermost/data      - ./mm-config:/mattermost/config      - ./mm-logs:/mattermost/logs      - ./mm-plugins:/mattermost/plugins    ports:      - "127.0.0.1:8065:8065"   caddy:    image: caddy:2-alpine    restart: unless-stopped    ports: ["80:80", "443:443"]    volumes:      - ./Caddyfile:/etc/caddy/Caddyfile      - caddy_data:/data volumes:  caddy_data:
Terminal3. Cài qua Docker Composebash
# Caddyfilechat.your-domain.com {    reverse_proxy mattermost:8065    encode gzip    request_body {        max_size 100MB    }}
Terminal3. Cài qua Docker Composebash
docker compose up -ddocker compose logs -f mattermost # Truy cập https://chat.your-domain.com# Setup wizard: tạo admin owner, tên team, channel "Town Square" default

4. Cấu hình System Console

  • Login admin, vào Settings -> System Console.
  • General -> Configuration -> Site URL: https://chat.your-domain.com (quan trọng cho email link).
  • Notifications -> Email -> setup SMTP (Gmail App Password hoặc Mailgun) để gửi invitation.
  • Files -> Storage -> Maximum File Size 100MB (mặc định 50MB).
  • Customization -> Site Name, Favicon - branding theo company.

5. Cấu hình OAuth Google/GitLab

  • Google Cloud Console -> Create OAuth Client. Redirect: https://chat.your-domain.com/signup/google/complete.
  • System Console -> Authentication -> Google OAuth 2.0 -> paste Client ID + Secret.
  • Restrict domain (Yêu cầu email kết thúc với @your-company.com).
  • Test: logout, login lại bằng Google.

Team Edition free hỗ trợ Google + GitLab OAuth. Enterprise có SAML, Okta. Với team dev VN, Google + GitHub OAuth là đủ.

6. Mobile push notification

Push notification iOS/Android cần proxy server (Mattermost Push Notification Service). Self-host hoặc dùng MM hosted free:

  • System Console -> Notifications -> Push -> select "Use HPNS connection with uptime SLA" (free, Mattermost host).
  • Hoặc self-host MM Push Server riêng (cần Apple Push cert, FCM token Google).
  • Test trên Mattermost mobile app (App Store / Google Play), connect tới chat.your-domain.com.

7. Plugin GitHub/Jira integration

  • System Console -> Plugins -> Plugin Marketplace.
  • Install GitHub plugin (free), configure webhook GH repo -> Mattermost channel #engineering.
  • Lúc PR opened, merge, comment -> auto post vào channel.
  • Jira plugin: connect Jira instance, link issue trong message với JIRA-123 auto unfurl.
  • Zoom plugin: tạo meeting Zoom từ command /zoom trong chat.

8. Bot và webhook

PowerShell8. Bot và webhookpowershell
# Tạo incoming webhook# Main Menu -> Integrations -> Incoming Webhooks -> Add# URL: https://chat.your-domain.com/hooks/xxx-xxx-xxx curl -X POST https://chat.your-domain.com/hooks/xxx-xxx-xxx   -H "Content-Type: application/json"   -d '{    "channel": "engineering",    "username": "DeployBot",    "icon_emoji": ":rocket:",    "text": "Deploy v1.2.3 to production successful"  }'

Webhook tích hợp với GitHub Actions, n8n, Jenkins, Prometheus alert. Slash command tự định nghĩa qua System Console.

9. Search và performance

Mattermost Team dùng Bleve full-text search Go-native. Đủ cho team <200 user, 1M message. Lớn hơn cần Elasticsearch (chỉ Enterprise).

  • Search hỗ trợ from:user, in:channel, before:date, after:date.
  • Index file attachment (PDF, DOCX) cho searchable.
  • Tối ưu: cleanup message cũ >1 năm nếu DB quá lớn (System Console -> Data Retention).

10. Backup hằng đêm

Terminal10. Backup hằng đêmbash
# /opt/mattermost/backup.sh#!/bin/bashDATE=$(date +%F)mkdir -p /backup/mm docker compose -f /opt/mattermost/docker-compose.yml exec -T postgres   pg_dump -U mmuser mattermost | gzip > /backup/mm/db-$DATE.sql.gz tar -czf /backup/mm/data-$DATE.tar.gz -C /opt/mattermost mm-data mm-config find /backup/mm -mtime +14 -delete # Cron0 3 * * * /opt/mattermost/backup.sh

File upload chiếm 80-90% disk. VPS 100GB SSD cho team 50 user 1 năm là đủ. Backup tar.gz có thể sync R2/S3 cho disaster recovery cross-region.

11. Migrate từ Slack

  • Slack Workspace -> Settings -> Import/Export Data -> Export.
  • Tải file ZIP message + user list.
  • Mattermost mmctl CLI: mmctl import slack <team> slack-export.zip.
  • Verify channels, user mapping, file attachment.
  • Communicate team chuyển sang, give 1-2 tuần parallel run.

12. Monitor và logs

  • Bật metric Prometheus: System Console -> Performance Monitoring.
  • Scrape /metrics endpoint với Prometheus, dashboard Grafana official.
  • Alert: latency > 500ms, concurrent user spike, DB connection pool full.
  • Logs xem qua docker logs mattermost, ship lên Loki nếu cần search.

FAQ

Mattermost Team Edition free có giới hạn gì so với Enterprise?

Team free: không SAML SSO, không Elasticsearch search, không compliance export, không read-only channel. Đủ cho 95% team SME <200 user. Enterprise (~10$/user/tháng) chỉ cần khi compliance nghiêm (finance, healthcare) hoặc team >500 user cần SSO Okta/Azure AD.

Mattermost có voice/video call không?

Có plugin Mattermost Calls (free, dùng WebRTC peer-to-peer hoặc rfc5766 TURN server). Voice call 1-1 hoặc nhóm 8-10 người ổn. Video call chất lượng kém Zoom/Meet, không phù hợp meeting chính thức. Cho daily standup hoặc quick chat tốt. Cần TURN server riêng cho user qua NAT.

Có thể migrate ngược từ Mattermost sang Slack được không?

Khó. Mattermost không có official export sang Slack format. Có thể export JSON message + file, viết script convert. Mất công vài ngày cho dataset trung bình. Suy nghĩ kỹ trước khi switch để tránh lock-in lại lần nữa.

Push notification iOS có hoạt động ổn không?

Với HPNS (Mattermost hosted push, free), iOS push hoạt động tốt, delay 1-3s. Android delay 0.5-2s qua FCM. Reliability ~99%. Self-host push server phức tạp (Apple cert, FCM), chỉ cần nếu compliance không cho phép data đi qua server thứ ba.

Mattermost có ăn nhiều RAM khi team đông?

Go runtime nhẹ. Mattermost server idle 300-500MB, peak 1GB cho 200 concurrent user. Postgres ~400MB cho DB 5GB. VPS 4GB chạy thoải mái team 200 active user. VPS 8GB cho 500-1000 user. Scale ngang qua HA cluster (Enterprise only).

Có bot framework để tự code custom integration không?

Có. Bot framework đầy đủ qua mattermost-bot-sample-golang hoặc mattermost.js (Node.js). Tạo bot account trong System Console, lấy access token, bot subscribe event qua WebSocket. Phù hợp viết bot deploy automation, alert from Prometheus, daily standup reminder.

Chia sẻ:Facebook

Thanh Nguyễn

TND

Tư vấn bản quyền, VPS và máy chủ kèm hóa đơn VAT, hợp đồng đầy đủ cho doanh nghiệp.