Kanzi is a powerful self-hosted application designed for managing and processing data with a focus on customization and full control. Ideal for developers and system administrators, Kanzi provides a robust set of features that can be tailored to specific workflows, making it an excellent choice for those prioritizing data privacy and flexibility. This guide walks you through deploying Kanzi, configuring it for production use, managing logs, setting up backups, and utilizing its advanced features.
Installing Kanzi
π¦ Docker/Docker Compose Setup
To quickly deploy Kanzi using Docker, create a docker-compose.yml
file with the appropriate configuration. Hereβs an example:
version: '3.8'
services:
kanzi:
image: kanziapp/kanzi:latest
container_name: kanzi
ports:
- "8080:8080"
volumes:
- ./data:/app/data
- ./config:/app/config
environment:
- KANZI_ENV=production
- KANZI_SECRET_KEY=your-secret-key
- KANZI_DB_URL=sqlite:////app/data/kanzi.db
restart: unless-stopped
Run the following commands to deploy Kanzi via Docker:
mkdir kanzi && cd kanzi
curl -O https://raw.githubusercontent.com/kanziapp/kanzi/main/docker-compose.yml
docker-compose up -d
This will pull the Kanzi image, start the container, and bind ports for local access.
π Manual Installation
If Docker isnβt an option, you can manually install Kanzi on a Linux server. Hereβs how:
- Install dependencies:
sudo apt update
sudo apt install -y python3 python3-pip sqlite3
- Clone the Kanzi repository and install dependencies:
git clone https://github.com/kanziapp/kanzi.git
cd kanzi
pip3 install -r requirements.txt
- Start Kanzi:
python3 app.py
Kanzi will now be available on http://localhost:8080
.
Configuring Nginx as a Reverse Proxy
π Nginx Configuration
To serve Kanzi via Nginx, create a server block configuration file for your domain:
server {
listen 80;
server_name kanzi.example.com;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Save this file as /etc/nginx/sites-available/kanzi
and link it to the sites-enabled
directory:
sudo ln -s /etc/nginx/sites-available/kanzi /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
π SSL/TLS Setup
Secure your Kanzi instance with Let's Encrypt SSL certificates:
sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d kanzi.example.com
Certbot will automatically update your Nginx configuration to serve Kanzi over HTTPS.
π οΈ Testing and Reloading Nginx
Validate your Nginx configuration and reload the service:
sudo nginx -t
sudo systemctl reload nginx
Visit https://kanzi.example.com
to confirm Kanzi is accessible over HTTPS.
Logging and Debugging Kanzi
ποΈ Enabling Debug Logs
Enable debug-level logging for Kanzi by modifying the config.yml
file:
logging:
level: debug
Restart Kanzi to apply the changes.
π Viewing Logs
If running Kanzi via Docker:
docker logs kanzi
For manual installations, check the logs in the logs
directory:
tail -f /app/logs/kanzi.log
π οΈ Troubleshooting Common Issues
Use logs to identify common errors such as misconfigured environment variables or database connection issues. For example, ensure the KANZI_SECRET_KEY
is properly set.
π€ Exporting Logs
Ship Kanzi logs to an ELK Stack instance for advanced analysis:
docker run -d --name logstash -p 5044:5044 logstash:latest
Update Kanziβs logging config to forward logs to Logstash.
Backup and Restore
ποΈ File-Based Backups
Backup critical directories:
tar -czf kanzi_backup_$(date +%F).tar.gz data config
π Database Backups
Export the SQLite database:
sqlite3 /app/data/kanzi.db .dump > kanzi_db_backup.sql
Restore it with:
sqlite3 /app/data/kanzi.db < kanzi_db_backup.sql
π Automated Backup Scripts
Automate backups with a cron job. Create a script backup.sh
:
#!/bin/bash
tar -czf /backups/kanzi_backup_$(date +%F).tar.gz /app/data /app/config
Make it executable and schedule it:
chmod +x backup.sh
crontab -e
## Add: 0 2 * * * /path/to/backup.sh
Updating and Upgrading Kanzi
β¬οΈ Updating Docker Images
To update Kanzi when using Docker:
docker-compose pull
docker-compose down
docker-compose up -d
π οΈ Manual Updates
For manual installations, pull the latest code from the repository:
cd kanzi
git pull origin main
pip3 install --upgrade -r requirements.txt
python3 app.py
π Checking for Updates
Visit the Kanzi GitHub repository for release notes or announcements about updates.
Leveraging Kanziβs Unique Features
π§ Enabling APIs
Enable Kanziβs API by adding this to your config.yml
:
api:
enabled: true
key: your-api-key
Test the API with curl
:
curl -H "Authorization: Bearer your-api-key" http://localhost:8080/api/v1/resources
π Advanced Configurations
Integrate third-party tools like Redis by configuring the config.yml
file:
redis:
host: localhost
port: 6379
password: your-redis-password
Restart Kanzi to enable the integration.
Wrapping Up
This guide has provided a comprehensive walkthrough of deploying, configuring, and managing Kanzi, from installation to advanced feature utilization. By following these steps, you can fully harness the power of Kanzi while maintaining complete control over your data. Get started today and enjoy the flexibility of self-hosting with Kanzi!