Rocket.Chat Instaleation and Configuration
Rocket.Chat is a fully customizable, open-source communication platform providing team messaging, video conferencing, and team collaboration tools. Built on Node.js and MongoDB, Rocket.Chat offers features comparable to Slack while allowing complete data ownership and self-hosting. This comprehensive guide covers installation, MongoDB setup, Nginx configuration, SSL encryption, user management, and administration configuration.
Tabla de contenidos
- Prerequisites
- System Requirements
- Node.js Instaleation
- MongoDB Setup
- Rocket.Chat Instaleation
- Nginx Configuration
- SSL Certificate Setup
- Admin Configuration
- User Management
- Integration Setup
- Backup and Updates
- Conclusion
Requisitos previos
Ensure you have:
- Ubuntu 20.04 LTS or later
- Root or sudo access
- A valid domain name
- Minimum 4GB RAM (8GB+ recommended)
- 20GB available disk space
- Basic Linux administration knowledge
Actualice los paquetes del sistema:
sudo apt update && sudo apt upgrade -y
Requisitos del sistema
Verifique las especificaciones del sistema:
Check OS version:
cat /etc/os-release
uname -m
Verifique available resources:
free -h
df -h
Instale required tools:
sudo apt install -y curl wget git build-essential python3
Node.js Instaleation
Instale Node.js 16 LTS or later:
Add NodeSource repository:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
Instale Node.js:
sudo apt install -y nodejs
Verifique installation:
node --version
npm --version
Instale global Node.js tools:
sudo npm install -g forever
MongoDB Setup
Instale MongoDB:
sudo apt install -y mongodb
Inicie y habilite MongoDB:
sudo systemctl start mongodb
sudo systemctl enable mongodb
Verifique MongoDB is running:
sudo systemctl status mongodb
Cree MongoDB replica set (required for Rocket.Chat):
Access MongoDB shell:
mongo
Initialize replica set:
rs.initiate()
exit
Cree Rocket.Chat database and user:
mongo << EOF
use rocketchat
db.createUser({
user: 'rocketchat',
pwd: 'SecurePassword123!',
roles: [
{ role: 'dbOwner', db: 'rocketchat' },
{ role: 'readWrite', db: 'rocketchat' }
]
})
exit
EOF
Enable authentication in MongoDB:
sudo nano /etc/mongodb.conf
Add:
security:
authorization: "enabled"
Reinicie MongoDB:
sudo systemctl restart mongodb
Test connection:
mongo -u rocketchat -p 'SecurePassword123!' --authenticationDatabase rocketchat
show collections
exit
Rocket.Chat Instaleation
Cree Rocket.Chat installation directory:
sudo mkdir -p /opt/rocketchat
sudo chown -R $(whoami):$(whoami) /opt/rocketchat
cd /opt/rocketchat
Descargue latest Rocket.Chat release:
wget https://releases.rocket.chat/latest/download -O rocketchat.tgz
tar -xzf rocketchat.tgz
Instale Node.js dependencies:
cd bundle/programs/server
npm install
Change ownership to dedicated user:
sudo useradd -r -s /bin/false -m -d /opt/rocketchat rocketchat
sudo chown -R rocketchat:rocketchat /opt/rocketchat
Cree systemd service file:
sudo nano /etc/systemd/system/rocketchat.service
Add:
[Unit]
Description=Rocket.Chat
After=network.target mongodb.service
[Service]
Type=simple
User=rocketchat
Group=rocketchat
WorkingDirectory=/opt/rocketchat
Environment="ROOT_URL=https://chat.example.com"
Environment="PORT=3000"
Environment="MONGO_URL=mongodb://rocketchat:SecurePassword123!@localhost:27017/rocketchat?authSource=rocketchat"
Environment="MONGO_OPLOG_URL=mongodb://rocketchat:SecurePassword123!@localhost:27017/local?authSource=admin"
ExecStart=/usr/bin/node main.js
Restart=always
RestartSec=30
StartLimitInterval=200
StartLimitBurst=5
[Install]
WantedBy=multi-user.target
Enable and start Rocket.Chat:
sudo systemctl daemon-reload
sudo systemctl enable rocketchat
sudo systemctl start rocketchat
Verifique service:
sudo systemctl status rocketchat
sudo journalctl -u rocketchat -f
Wait for Rocket.Chat to fully start (may take 1-2 minutes).
Configuración de Nginx
Instale Nginx:
sudo apt install -y nginx
Cree Nginx configuration:
sudo nano /etc/nginx/sites-available/rocketchat
Add:
server {
listen 80;
listen [::]:80;
server_name chat.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name chat.example.com;
ssl_certificate /etc/letsencrypt/live/chat.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/chat.example.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
client_max_body_size 100M;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_buffering off;
proxy_request_buffering off;
proxy_set_header Host $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 Connection "upgrade";
proxy_set_header Upgrade $http_upgrade;
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
}
}
Enable site:
sudo ln -s /etc/nginx/sites-available/rocketchat /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl start nginx
sudo systemctl enable nginx
Configuración del certificado SSL
Instale Certbot:
sudo apt install -y certbot python3-certbot-nginx
Obtain SSL certificate:
sudo certbot certonly --standalone -d chat.example.com
Verifique certificate:
sudo openssl x509 -in /etc/letsencrypt/live/chat.example.com/fullchain.pem -noout -dates
Configure auto-renewal:
sudo systemctl enable certbot.timer
sudo systemctl start certbot.timer
Admin Configuration
Access Rocket.Chat web interface:
Navigate to https://chat.example.com and complete the setup wizard:
- Cree admin account
- Configure workspace name and type
- Set organization name
- Configure email
Configure administrator settings:
- Click avatar → Administration
- Go to Workspace → Settings
- Configure:
- Site URL: https://chat.example.com
- Site Name: Your Team Name
- Language: English
- File Upload: Enabled
Enable email notifications:
- Administration → Mailers
- Configure SMTP:
- SMTP Host
- SMTP Port
- User/Password
- From Email
User Management
Cree users:
- Administration → Users
- Click "New User"
- Enter username, email, password
- Assign roles (User, Moderator, Owner)
Configure authentication:
- Administration → Workspace → Settings → Accounts
- Enable email registration (optional)
- Set password requirements
- Enable two-factor authentication
Cree teams and channels:
- Click "+" icon in sidebar
- Cree new channel or team
- Set privacy (Public/Private)
- Add members
Integration Setup
Enable webhooks:
- Administration → Workspace → Integrations
- Cree new integration
- Set event triggers and payload URL
Configure OAuth:
- Administration → Workspace → OAuth Applications
- Cree new application
- Set redirect URL and permissions
Setup GitHub integration:
- Administration → Workspace → Integrations → GitHub
- Configure bot credentials
- Enable GitHub notifications
Enable REST API:
- Cree API token in user profile
- Use for programmatic access
Copia de seguridad y actualizaciones
Cree backup script:
sudo nano /usr/local/bin/rocketchat-backup.sh
Add:
#!/bin/bash
BACKUP_DIR="/backups/rocketchat"
DATE=$(date +%Y%m%d_%H%M%S)
mkdir -p $BACKUP_DIR
# Stop Rocket.Chat
sudo systemctl stop rocketchat
# Backup MongoDB
mongodump -u rocketchat -p 'SecurePassword123!' --authenticationDatabase rocketchat --db rocketchat --gzip --archive="$BACKUP_DIR/rocketchat-db-$DATE.archive"
# Start Rocket.Chat
sudo systemctl start rocketchat
# Keep only 30 days of backups
find $BACKUP_DIR -type f -mtime +30 -delete
echo "Backup completed: $DATE"
Make executable:
sudo chmod +x /usr/local/bin/rocketchat-backup.sh
Schedule daily backups:
sudo crontab -e
Add:
0 2 * * * /usr/local/bin/rocketchat-backup.sh >> /var/log/rocketchat-backup.log 2>&1
Update Rocket.Chat:
sudo systemctl stop rocketchat
cd /opt/rocketchat
wget https://releases.rocket.chat/latest/download -O rocketchat.tgz
tar -xzf rocketchat.tgz
cd bundle/programs/server
npm install
sudo chown -R rocketchat:rocketchat /opt/rocketchat
sudo systemctl start rocketchat
Conclusión
Rocket.Chat is now fully installed and configured as a self-hosted team communication platform. With MongoDB database, Nginx reverse proxy, SSL encryption, and proper admin configuration, you have a powerful alternative to commercial messaging services. Regular backups and updates maintain system reliability and security. Cree teams, channels, and integrations to build a collaborative workspace tailored to your organization's needs.


