Rocket.Chat is an open-source, self-hosted communication platform designed to provide secure, flexible, and highly customizable collaboration for teams. Itβs an excellent choice for organizations that need complete control over their data and want a feature-rich alternative to proprietary messaging platforms. In this guide, weβll cover everything from installing Rocket.Chat to configuring it with Nginx, managing logs, creating backups, and leveraging its advanced features.
Installing Rocket.Chat
π¦ Docker/Docker Compose Setup
Docker is the most efficient method for deploying Rocket.Chat, as it simplifies dependency management and provides portability.
- Create a
docker-compose.yml
file to define the Rocket.Chat and MongoDB containers:
version: '3'
services:
rocketchat:
image: rocketchat/rocket.chat:latest
restart: unless-stopped
environment:
MONGO_URL: mongodb://mongo:27017/rocketchat
ROOT_URL: http://localhost:3000
PORT: 3000
ports:
- 3000:3000
depends_on:
- mongo
volumes:
- ./uploads:/app/uploads
mongo:
image: mongo:4.4
restart: unless-stopped
volumes:
- ./data/db:/data/db
- Deploy via Docker Compose:
docker-compose up -d
This launches Rocket.Chat on port 3000, with MongoDB as the backend.
- Verify that Rocket.Chat is running:
docker ps
curl http://localhost:3000
π Manual Installation
If you prefer a manual setup, follow these steps on a Linux server (e.g., Ubuntu 20.04):
- Install Node.js and MongoDB:
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt install -y nodejs mongodb
- Download and extract Rocket.Chat:
wget https://releases.rocket.chat/latest/download -O rocket.chat.tgz
tar -xvzf rocket.chat.tgz
cd bundle/programs/server
npm install
- Configure and run Rocket.Chat:
export MONGO_URL=mongodb://localhost:27017/rocketchat
export ROOT_URL=http://localhost:3000
export PORT=3000
node main.js
Rocket.Chat will now be accessible at http://<server-ip>:3000
.
Configuring Nginx as a Reverse Proxy
π Nginx Configuration
Set up Nginx as a reverse proxy to improve performance and allow SSL termination.
- Install Nginx:
sudo apt update
sudo apt install -y nginx
- Create an Nginx config file for Rocket.Chat (e.g.,
/etc/nginx/sites-available/rocketchat
):
server {
server_name chat.example.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
}
- Enable the configuration:
sudo ln -s /etc/nginx/sites-available/rocketchat /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
π SSL/TLS Setup
Secure your Rocket.Chat instance with Letβs Encrypt.
- Install Certbot:
sudo apt install -y certbot python3-certbot-nginx
- Obtain and apply an SSL certificate:
sudo certbot --nginx -d chat.example.com
- Automate certificate renewal:
sudo crontab -e
Add this line to run the renewal daily:
0 0 * * * certbot renew --quiet
π οΈ Testing and Reloading Nginx
Ensure the Nginx config is active and secure:
sudo nginx -t
sudo systemctl reload nginx
Logging and Debugging Rocket.Chat
ποΈ Enabling Debug Logs
Increase log verbosity to debug issues effectively.
- Edit the container or environment variable settings:
docker exec -it <rocketchat-container-id> bash
export LOG_LEVEL=debug
- Restart the container to apply changes:
docker restart <rocketchat-container-id>
π Viewing Logs
Access logs from the Rocket.Chat container:
docker logs <rocketchat-container-id>
For manual installations, check log files in the application directory:
tail -f /path/to/rocket.chat/logs
π οΈ Troubleshooting Common Issues
If Rocket.Chat fails to start, inspect MongoDB availability:
docker exec -it <mongo-container-id> mongo --eval 'db.stats()'
Look for missing environment variables in the logs.
Backup and Restore
ποΈ File-Based Backups
Backup Rocket.Chat data by saving the volumes:
tar -czvf backup.tar.gz ./uploads ./data/db
π Database Backups
Export MongoDB data for Rocket.Chat:
docker exec <mongo-container-id> mongodump --out /data/backup
Restore it with:
docker exec <mongo-container-id> mongorestore /data/backup
π Automated Backup Scripts
Create a cron job for periodic backups:
crontab -e
Add this line:
0 2 * * * tar -czvf /backups/backup-$(date +\%F).tar.gz /path/to/rocketchat/data
Updating and Upgrading Rocket.Chat
β¬οΈ Updating Docker Images
Pull the latest Rocket.Chat image and redeploy:
docker-compose pull
docker-compose up -d
π οΈ Manual Updates
For manual installations:
- Download the latest version and repeat the manual installation steps.
π Checking for Updates
Check the Docker Hub repository for new versions:
docker search rocketchat
Leveraging Rocket.Chatβs Unique Features
π§ Enabling APIs
Rocket.Chat has a robust REST API for automation.
-
Enable APIs in the admin panel and generate a personal access token.
-
Test the API with
curl
:
curl -X GET https://chat.example.com/api/v1/info -H "X-Auth-Token: <your-token>" -H "X-User-Id: <your-user-id>"
π Advanced Configurations
Integrate third-party tools like Slack-compatible webhooks:
curl -X POST -H 'Content-Type: application/json' --data '{"text": "Hello, Rocket.Chat!"}' https://chat.example.com/hooks/<webhook_id>
Wrapping Up
This guide provided a comprehensive walkthrough of installing, configuring, and managing Rocket.Chat, along with leveraging its advanced features. By following these steps, you can deploy a highly secure and customizable communication platform that gives you complete control over your data. Start implementing today and experience the full potential of Rocket.Chat for team collaboration!