Skip to content

MatinSenPai/Zanjir

Repository files navigation

Zanjir - Matrix Server

Self-hosted, fast, lightweight Matrix server powered by Conduit (Rust)

License: MIT Docker Matrix


zanjir-screens-copy.webp

Video Tutorial

Zanjir Project Introduction

📖 Persian Version (نسخه فارسی)


Important

Upgrading from Dendrite? If you previously installed Zanjir with Dendrite, you need to migrate to the new Conduit-based version. This will require a fresh installation and all data will be lost. See the Migration Guide for step-by-step instructions.


📋 Table of Contents


✨ Features

Feature Description
🔐 Open Registration Users can self-register via web interface
👑 Admin Panel Web-based admin dashboard with audit logging
📞 Voice/Video Calls TURN server for reliable NAT traversal
🔧 Custom Ports Configurable HTTPS/HTTP ports (no 443 conflict)
📱 Element Web Modern, responsive Matrix client
🇮🇷 Persian UI Fully translated interface
🐳 Docker Powered One-command installation
🔒 Auto HTTPS Let's Encrypt or self-signed certificates

🚀 Quick Start

Requirements:

  • Ubuntu 20.04+ or Debian 11+
  • 2GB RAM minimum
  • Domain name (or IP address)
  • Ports: 80, 443 (or custom), 3478, 5349 (UDP)

One-line installation:

git clone https://github.com/MatinSenPai/zanjir.git ~/zanjir
cd ~/zanjir
sudo bash install.sh

Access:

  • Web App: https://your-domain.com
  • Admin Panel: https://your-domain.com/admin

📦 Installation

Step 1: Clone Repository

git clone https://github.com/MatinSenPai/zanjir.git
cd zanjir

Step 2: Run Installer

sudo bash install.sh

Installation prompts:

  1. Server address - Your domain or IP (e.g., matrix.example.com or 185.123.45.67)
  2. Admin email - For SSL certificates (domain mode only)
  3. HTTPS port - Default: 443 (press Enter), or custom (e.g., 8443)

Step 3: Create Admin User

After installation completes:

docker exec -it zanjir-dendrite /usr/bin/create-account \
    --config /etc/dendrite/dendrite.yaml \
    --username YOUR_USERNAME \
    --admin

Example:

docker exec -it zanjir-dendrite /usr/bin/create-account \
    --config /etc/dendrite/dendrite.yaml \
    --username admin \
    --admin

You'll be prompted to set a password.


🎛️ Management

After installation, use the zanjir command to manage your server:

zanjir

Available Commands

zanjir              # Interactive menu
zanjir status       # Show service status
zanjir logs         # View logs (all services)
zanjir logs conduit # View specific service logs
zanjir restart      # Restart all services
zanjir start        # Start all services
zanjir stop         # Stop all services
zanjir update       # Update to latest version
zanjir backup       # Backup all data
zanjir uninstall    # Completely remove Zanjir

Interactive Menu

When you run zanjir without arguments, you'll see a beautiful interactive menu:

╔═══════════════════════════╗
║                           ║
║      Z A N J I R ⛓️       ║
║                           ║
╚═══════════════════════════╝

Matrix Server Management Tool
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Main Menu:

  1. Show Status
  2. View Logs
  3. Restart Services
  4. Start Services
  5. Stop Services
  6. Update Zanjir
  7. Backup Data
  8. Uninstall
  9. Exit

👤 User Guide

Registration

  1. Visit https://your-domain.com
  2. Click "Create account"
  3. Fill in username and password
  4. Start messaging!

Using Element Web

  • Create Room: Click + button → New Room
  • Invite Users: Room settings → Invite users → Enter @username:your-domain.com
  • Send Messages: Type and press Enter
  • Voice Call: Click phone icon in room header
  • Video Call: Click video icon in room header

Mobile Apps

Android:

iOS:

Configuration:

  • Homeserver URL: https://your-domain.com
  • Identity server: Leave blank

🛡️ Admin Panel

Access

Visit: https://your-domain.com/admin

Login with your admin account credentials.

Features

Dashboard

  • Total users count
  • Active users
  • Total rooms

User Management

  • View all users
  • Disable user accounts
  • Delete users
  • View user status

Audit Logs

  • Track all admin actions
  • Timestamps and IP addresses
  • Target user tracking
  • Detailed action logs

Admin Actions

Disable a user:

  1. Go to Users page
  2. Find user
  3. Click "Disable"

Delete a user:

  1. Go to Users page
  2. Find user
  3. Click "Delete" → Confirm

All actions are automatically logged and visible in the Logs page.


📞 Voice/Video Calls

Zanjir includes a TURN server (coturn) for reliable voice/video calls.

How It Works

TURN server helps users behind NAT/firewalls connect:

  • Direct P2P when possible
  • TURN relay when necessary
  • Automatic fallback

Firewall Configuration

Required ports:

Port Protocol Purpose
3478 UDP STUN/TURN
5349 UDP TURN-TLS

UFW example:

sudo ufw allow 3478/udp
sudo ufw allow 5349/udp

Testing Calls

  1. Create two accounts
  2. Create a room, invite both users
  3. Click phone/video icon
  4. Accept call on other end

🔧 Custom Port

If port 443 is already in use, you can use a custom port.

Installation with Custom Port

During install.sh, enter your desired port:

HTTPS port (default: 443): 8443

This will:

  • Use port 8443 for HTTPS
  • Use port 8080 for HTTP (auto-calculated)
  • Update all configurations

Accessing with Custom Port

https://your-domain.com:8443

Changing Port After Installation

  1. Edit .env:
    nano .env
  2. Change HTTPS_PORT and HTTP_PORT
  3. Restart services:
    docker compose down
    docker compose up -d

🔍 Troubleshooting

Common Issues

Docker Installation fails (Iranian VPS)

Error: connection refused to download.docker.com

Solution: Script automatically uses Iranian mirrors:

  • docker.arvancloud.ir
  • registry.docker.ir

Registration not working

Check:

  1. Verify registration is enabled in docker-compose.yml: CONDUIT_ALLOW_REGISTRATION: "true"
  2. Check element-config.json: "UIFeature.registration": true
  3. Restart containers:
    docker compose restart

Voice calls failing

Solutions:

  1. Check TURN server is running:
    docker ps | grep coturn
  2. Verify firewall allows UDP 3478, 5349
  3. Check TURN secret in .env matches TURN_SECRET environment variable

Admin panel login fails

Solutions:

  1. Verify user is admin:
    docker exec -it zanjir-dendrite /usr/bin/create-account \
        --config /etc/dendrite/dendrite.yaml \
        --username YOUR_USERNAME \
        --admin
  2. Check admin container logs:
    docker logs zanjir-admin

Port already in use

Solution: Use custom port during installation, or change port in .env


❓ FAQ

General

Q: Can I use an IP address instead of domain?
A: Yes! The installer detects IP mode and uses self-signed certificates.

Q: Is federation enabled?
A: No, Zanjir is designed for isolated single-server deployment.

Q: Can users video call externally?
A: Only within your Zanjir server (federation disabled).

Security

Q: How are passwords stored?
A: Bcrypt hashed in PostgreSQL.

Q: Is end-to-end encryption supported?
A: Yes! Element/Matrix supports E2EE by default.

Q: What about audit logs?
A: Admin actions logged in SQLite (admin/audit_log.db).

Performance

Q: How many users can it handle?
A: Conduit is extremely lightweight. A 1GB VPS can handle ~100-500 users with ease. Conduit uses ~50MB RAM vs Dendrite's 200-500MB.

Q: What about backups?
A: Backup Docker volumes:

docker run --rm \
  -v zanjir-postgres-data:/data \
  -v $(pwd):/backup \
  ubuntu tar czf /backup/postgres-backup.tar.gz /data

🤝 Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

📄 License

MIT License - see LICENSE file


🙏 Acknowledgments


📞 Support


Made with ❤️ for secure, private communication

About

زنجیر یه بسته‌بندی آماده از پروتکل Matrix هست که برای شرایط ایران بهینه شده. هدف اینه که بتونی روی یه VPS اوبونتوی ایرانی، سرور پیام‌رسان شخصی خودت رو زیر ۵ دقیقه بالا بیاری.

Resources

Stars

Watchers

Forks

Contributors