Deploying Flexisip
Introduction
Flexisip is a powerful, open-source SIP (Session Initiation Protocol) proxy server developed by Belledonne Communications. Designed for VoIP and real-time communications, Flexisip provides enterprise-grade SIP routing, load balancing, presence management, and push notification support for mobile devices. Built with scalability and reliability in mind, it handles millions of messages and calls daily for telecom operators and businesses worldwide.
Deploying Flexisip on Klutch.sh gives you automatic Dockerfile detection, persistent storage for configuration and logs, TCP traffic support for SIP signaling, and seamless scaling capabilities. This guide provides detailed instructions for deploying Flexisip with production-ready configuration, MySQL backend integration, Redis caching, and best practices for running a reliable VoIP infrastructure.
Why Deploy Flexisip on Klutch.sh?
- Automatic Dockerfile Detection: Klutch.sh detects your Dockerfile automatically and builds your container
- TCP Traffic Support: Native support for SIP signaling on TCP protocol
- Persistent Storage: Attach volumes for configuration files, logs, and certificates
- Instant HTTPS: Secure endpoints with automatic SSL/TLS certificates
- Database Integration: Easy connection to MySQL for user management and Redis for caching
- Easy Scaling: Scale your SIP infrastructure based on traffic demands
- GitHub Integration: Deploy directly from your GitHub repository
- High Availability: Run multiple instances for load balancing and failover
Prerequisites
Before deploying Flexisip on Klutch.sh, ensure you have:
- A Klutch.sh account
- A GitHub account with a repository for your project
- Docker installed locally for testing (optional but recommended)
- Basic familiarity with SIP protocol and VoIP concepts
- MySQL database (see our MySQL guide for deployment instructions)
- Redis cache (optional but recommended - see our Redis guide)
- Understanding of network protocols and port configuration
Understanding Flexisip Architecture
Flexisip follows a modular SIP server architecture designed for scalability:
Core Components:
- SIP Proxy: Handles SIP registration, routing, and message forwarding
- Presence Server: Manages user presence and availability status
- Conference Server: Enables multi-party audio/video conferencing
- Push Notification Gateway: Delivers push notifications to mobile devices (APNs, FCM)
- Load Balancer: Distributes traffic across multiple backend servers
- Media Relay: TURN/STUN server for NAT traversal and media routing
Default Configuration:
- SIP Port: 5060 (TCP/UDP)
- SIP TLS Port: 5061 (TLS)
- HTTP Admin Port: 8080
- Database: MySQL (user accounts, routing tables)
- Cache: Redis (registration cache, presence)
- Transport Protocols: TCP, UDP, TLS, WebSocket
Directory Structure:
/etc/flexisip/├── flexisip.conf # Main configuration file├── users.db # SQLite user database (dev)├── tls/ # TLS certificates│ ├── cert.pem│ └── key.pem└── modules/ # Module configurations
/var/log/flexisip/├── flexisip.log # Main log file└── errors.log # Error logs
/var/lib/flexisip/├── registrations/ # Registration cache└── presence/ # Presence dataInstallation and Setup
Step 1: Create Your Repository
Create a new GitHub repository for your Flexisip deployment:
mkdir flexisip-deploymentcd flexisip-deploymentgit initStep 2: Create the Dockerfile
- Uses Debian Bullseye as the base image
- Installs Flexisip from official Belledonne Communications repository
- Includes MySQL and Redis clients for backend connectivity
- Creates necessary directories for configuration and logs
- Exposes SIP ports (5060, 5061) and admin interface (8080)
- Includes health checks for monitoring
Create a Dockerfile in the root of your repository. This Dockerfile will set up Flexisip with all necessary dependencies:
FROM debian:bullseye-slim
# Install dependenciesRUN apt-get update && apt-get install -y \ wget \ gnupg2 \ software-properties-common \ lsb-release \ ca-certificates \ curl \ && rm -rf /var/lib/apt/lists/*
# Add Belledonne Communications repositoryRUN wget -O- https://linphone.org/snapshots/belledonne-communications-release.gpg | apt-key add - && \ echo "deb http://linphone.org/snapshots/debian bullseye main" > /etc/apt/sources.list.d/linphone.list
# Install FlexisipRUN apt-get update && apt-get install -y \ flexisip \ flexisip-presence \ mysql-client \ redis-tools \ && rm -rf /var/lib/apt/lists/*
# Create necessary directoriesRUN mkdir -p /etc/flexisip/tls \ /var/log/flexisip \ /var/lib/flexisip/registrations \ /var/lib/flexisip/presence
# Copy configuration filesCOPY flexisip.conf /etc/flexisip/flexisip.confCOPY docker-entrypoint.sh /usr/local/bin/RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Expose ports# SIP: 5060 (TCP/UDP), 5061 (TLS)# HTTP Admin: 8080# WebSocket: 5062EXPOSE 5060/tcp 5060/udp 5061/tcp 8080 5062
# Health checkHEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ CMD flexisip --check-config || exit 1
# Set entrypointENTRYPOINT ["docker-entrypoint.sh"]CMD ["flexisip", "--config-file", "/etc/flexisip/flexisip.conf"]This Dockerfile:
Step 3: Create Flexisip Configuration
- Multi-transport support (TCP, UDP, TLS)
- MySQL backend for user registration
- Redis caching for performance
- Push notification support for mobile devices
- HTTP admin interface for management
- Presence server integration
- TLS/encryption support
Create flexisip.conf with production-ready settings:
# Flexisip Configuration File
#### Global Settings##[global]# Server identityserver-name=flexisip-server# Transports (tcp, udp, tls)transports=sip:*:5060;transport=tcp sip:*:5060;transport=udp sips:*:5061;transport=tls# Number of threadsthreads=4# Log level: debug, message, warning, errorlog-level=message# Log filelog-file=/var/log/flexisip/flexisip.log
#### Module: Forward##[module::Forward]enabled=true# Route to backend SIP servers (if using as load balancer)# routes=sip:backend1.example.com;transport=tcp sip:backend2.example.com;transport=tcp
#### Module: Registrar##[module::Registrar]enabled=true# Database configurationdb-implementation=mysql# MySQL connection stringdb-connection-string=db='sip' user='${MYSQL_USER}' password='${MYSQL_PASSWORD}' host='${MYSQL_HOST}' port='${MYSQL_PORT}'# Registration expiration time (seconds)reg-expire=3600# Maximum registrations per addressmax-contacts-per-address=10
# Redis cache for registrations (optional but recommended)redis-server-domain=${REDIS_HOST}redis-server-port=${REDIS_PORT}redis-auth-password=${REDIS_PASSWORD}
#### Module: Authentication##[module::Authentication]enabled=true# Authentication databaseauth-domains=sip.example.com# Database for authenticationdb-implementation=mysqldb-connection-string=db='sip' user='${MYSQL_USER}' password='${MYSQL_PASSWORD}' host='${MYSQL_HOST}' port='${MYSQL_PORT}'# Algorithm: MD5, SHA256hashing-algorithm=SHA256# Disable authentication (for testing only)# disable-authentication=false
#### Module: Presence##[module::Presence]enabled=true# Presence server configurationpresence-server=sip:presence.example.com# Database for presencedb-implementation=redisredis-server-domain=${REDIS_HOST}redis-server-port=${REDIS_PORT}redis-auth-password=${REDIS_PASSWORD}
#### Module: Router##[module::Router]enabled=true# Static routes (optional)# static-targets=sip:backend.example.com
#### Module: PushNotification##[module::PushNotification]enabled=true# Apple Push Notification Service (APNs)apns-certificate-path=/etc/flexisip/tls/apns-cert.pemapns-certificate-key-path=/etc/flexisip/tls/apns-key.pem# Firebase Cloud Messaging (FCM)firebase-service-account-file=/etc/flexisip/fcm-service-account.json# Maximum queue sizemax-queue-size=10000
#### Module: MediaRelay##[module::MediaRelay]enabled=false# STUN/TURN server configuration# stun-server=stun.example.com:3478# turn-server=turn.example.com:3478# turn-username=turnuser# turn-password=turnpassword
#### Module: Transcoder##[module::Transcoder]enabled=false# Audio codecs# audio-codecs=opus speex pcmu pcma
#### TLS Configuration##[tls]# TLS certificate and keytls-certificate-file=/etc/flexisip/tls/cert.pemtls-certificate-key-file=/etc/flexisip/tls/key.pem# TLS cipher suitestls-ciphers=HIGH:!aNULL:!MD5# Require client certificatetls-verify-client=false
#### HTTP Admin Interface##[http]enabled=truebind-address=0.0.0.0:8080# Enable CORSenable-cors=true# Admin authenticationadmin-username=${ADMIN_USERNAME}admin-password=${ADMIN_PASSWORD}This configuration includes:
Step 4: Create Docker Entrypoint Script
Create docker-entrypoint.sh for initialization:
#!/bin/bash
set -e
echo "Starting Flexisip initialization..."
# Check required environment variablesif [ -z "$MYSQL_HOST" ]; then echo "ERROR: MYSQL_HOST environment variable is required" exit 1fi
if [ -z "$MYSQL_USER" ]; then echo "ERROR: MYSQL_USER environment variable is required" exit 1fi
if [ -z "$MYSQL_PASSWORD" ]; then echo "ERROR: MYSQL_PASSWORD environment variable is required" exit 1fi
# Wait for MySQL to be readyecho "Waiting for MySQL at ${MYSQL_HOST}:${MYSQL_PORT:-3306}..."until mysql -h"$MYSQL_HOST" -P"${MYSQL_PORT:-3306}" -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" -e "SELECT 1" &> /dev/nulldo echo "MySQL is unavailable - sleeping" sleep 2doneecho "MySQL is up and ready!"
# Wait for Redis if configuredif [ -n "$REDIS_HOST" ]; then echo "Waiting for Redis at ${REDIS_HOST}:${REDIS_PORT:-6379}..." until redis-cli -h "$REDIS_HOST" -p "${REDIS_PORT:-6379}" -a "$REDIS_PASSWORD" ping &> /dev/null do echo "Redis is unavailable - sleeping" sleep 2 done echo "Redis is up and ready!"fi
# Initialize MySQL database if neededecho "Initializing Flexisip database..."mysql -h"$MYSQL_HOST" -P"${MYSQL_PORT:-3306}" -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" <<-EOSQL CREATE DATABASE IF NOT EXISTS sip CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE sip;
CREATE TABLE IF NOT EXISTS accounts ( id INT AUTO_INCREMENT PRIMARY KEY, username VARCHAR(255) NOT NULL, domain VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, algorithm VARCHAR(50) DEFAULT 'SHA256', enabled BOOLEAN DEFAULT TRUE, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, UNIQUE KEY unique_account (username, domain) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS registrations ( id INT AUTO_INCREMENT PRIMARY KEY, username VARCHAR(255) NOT NULL, domain VARCHAR(255) NOT NULL, contact VARCHAR(500) NOT NULL, expires INT NOT NULL, user_agent VARCHAR(255), created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, INDEX idx_user (username, domain), INDEX idx_expires (expires) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;EOSQL
echo "Database initialization complete!"
# Set proper permissionschown -R flexisip:flexisip /var/log/flexisip /var/lib/flexisip
# Validate configurationecho "Validating Flexisip configuration..."flexisip --check-config
echo "Starting Flexisip..."exec "$@"Make it executable:
chmod +x docker-entrypoint.shStep 5: Create Environment Configuration
Create .env.example to document environment variables:
# Flexisip Environment Configuration
# Application SettingsSERVER_NAME=flexisip-serverLOG_LEVEL=messageADMIN_USERNAME=adminADMIN_PASSWORD=changeme123
# MySQL Database Configuration (Required)MYSQL_HOST=mysql.example-app.klutch.shMYSQL_PORT=8000MYSQL_USER=flexisipMYSQL_PASSWORD=strongpassword123MYSQL_DATABASE=sip
# Redis Configuration (Optional but Recommended)REDIS_HOST=redis.example-app.klutch.shREDIS_PORT=8000REDIS_PASSWORD=redispassword123
# SIP Domain ConfigurationSIP_DOMAIN=sip.example.com
# Push Notifications (Optional)# APNS_CERTIFICATE_PATH=/etc/flexisip/tls/apns-cert.pem# APNS_KEY_PATH=/etc/flexisip/tls/apns-key.pem# FCM_SERVICE_ACCOUNT=/etc/flexisip/fcm-service-account.json
# TLS Configuration (Optional)# TLS_CERTIFICATE=/etc/flexisip/tls/cert.pem# TLS_KEY=/etc/flexisip/tls/key.pem
# Media Relay Configuration (Optional)# STUN_SERVER=stun.l.google.com:19302# TURN_SERVER=turn.example.com:3478# TURN_USERNAME=turnuser# TURN_PASSWORD=turnpasswordImportant: Never commit actual secrets to your repository. Set these as environment variables in Klutch.sh.
Step 6: Create README Documentation
- SIP domain and transports
- Authentication settings
- Database connections
- Module enablement
- TLS configuration
Create a README.md file:
# Flexisip SIP Server Deployment
This repository contains the Docker configuration for deploying Flexisip on Klutch.sh.
## Features
- Full SIP proxy server with registration and routing- MySQL backend for user management- Redis caching for performance- Push notification support (APNs, FCM)- TLS/encryption support- HTTP admin interface- Presence server integration
## Prerequisites
- MySQL database (deploy separately on Klutch.sh)- Redis cache (optional but recommended)- Valid TLS certificates (for production)- Push notification credentials (for mobile apps)
## Deployment
1. Push this repository to GitHub2. Deploy MySQL and Redis on Klutch.sh3. Create a new app on Klutch.sh4. Connect your GitHub repository5. Set environment variables for database connection6. Klutch.sh automatically detects and builds the Dockerfile7. Configure TCP traffic on port 50608. Attach persistent volumes for logs and config9. Deploy and test SIP connectivity
## Local Development
```bashdocker build -t flexisip .docker run -p 5060:5060 -p 8080:8080 \ -e MYSQL_HOST=localhost \ -e MYSQL_USER=flexisip \ -e MYSQL_PASSWORD=password \ flexisipConfiguration
Edit flexisip.conf to customize:
Monitoring
Access the admin interface at http://localhost:8080 with configured credentials.
</ol>
### Step 7: Push to GitHub
<ol>
Add all files and push to your GitHub repository:
```bash# Create .gitignorecat > .gitignore << 'EOF'.env*.log.DS_Store/var/log//var/lib/tls/*.pemtls/*.key*.jsonEOF
# Initialize git and commitgit add Dockerfile flexisip.conf docker-entrypoint.sh .env.example README.md .gitignoregit commit -m "Initial Flexisip deployment setup"git branch -M maingit remote add origin https://github.com/YOUR_USERNAME/flexisip-deployment.gitgit push -u origin mainDeploying to Klutch.sh
Now that your repository is ready, follow these steps to deploy Flexisip on Klutch.sh:
-
Deploy MySQL Database
Before deploying Flexisip, you need a MySQL database. Follow our MySQL deployment guide to set up MySQL on Klutch.sh.
Take note of:
- MySQL hostname (e.g.,
mysql-app.klutch.sh) - Database port (8000 for TCP traffic on Klutch.sh)
- Username and password
- Database name
- MySQL hostname (e.g.,
-
Deploy Redis Cache (Optional but Recommended)
For better performance, deploy Redis following our Redis deployment guide.
Take note of:
- Redis hostname (e.g.,
redis-app.klutch.sh) - Redis port (8000 for TCP traffic on Klutch.sh)
- Redis password
- Redis hostname (e.g.,
-
Log in to Klutch.sh
Navigate to klutch.sh/app and sign in with your account.
-
Create a New Project
Click “Create Project” and give your project a descriptive name like “Flexisip SIP Server”.
-
Create a New App
Inside your project, click “Create App” to start a new deployment.
-
Connect Your GitHub Repository
- Select GitHub as your source
- Authorize Klutch.sh to access your repositories if you haven’t already
- Choose the repository containing your Flexisip Dockerfile
- Select the branch you want to deploy (typically
main)
-
Configure Traffic Settings
- Select TCP as the traffic type (Flexisip uses TCP for SIP signaling)
- This enables external connections on port 8000, which routes to your internal container port
-
Set Internal Port
Set the internal port to 5060 (the default SIP port inside the container).
Klutch.sh will route external traffic from port 8000 to internal port 5060.
-
Add Environment Variables
Configure the following environment variables in the Klutch.sh dashboard:
Required Database Variables:
MYSQL_HOST: Your MySQL hostname (e.g.,mysql-app.klutch.sh)MYSQL_PORT:8000(Klutch.sh external port for TCP services)MYSQL_USER: Your MySQL usernameMYSQL_PASSWORD: Your MySQL password (mark as secret)MYSQL_DATABASE:sip
Optional Redis Variables:
REDIS_HOST: Your Redis hostname (e.g.,redis-app.klutch.sh)REDIS_PORT:8000REDIS_PASSWORD: Your Redis password (mark as secret)
Admin Interface:
ADMIN_USERNAME:adminADMIN_PASSWORD: Strong password (mark as secret)
SIP Configuration:
SERVER_NAME:flexisip-serverSIP_DOMAIN: Your SIP domain (e.g.,sip.example.com)LOG_LEVEL:message(ordebugfor troubleshooting)
-
Attach Persistent Volumes
This is crucial for preserving logs and configuration:
Volume 1 - Logs:
- Click “Add Volume”
- Mount Path:
/var/log/flexisip - Size: 5GB (adjust based on logging needs)
Volume 2 - Data:
- Click “Add Volume”
- Mount Path:
/var/lib/flexisip - Size: 10GB (for registration and presence cache)
Volume 3 - Configuration (Optional):
- Click “Add Volume”
- Mount Path:
/etc/flexisip - Size: 1GB (for persistent configuration and TLS certificates)
These volumes ensure your logs, registrations, and configuration persist across deployments.
-
Review and Deploy
- Review all configuration settings
- Click “Deploy” to start the build process
Klutch.sh will:
- Clone your repository
- Build the Docker image using your Dockerfile
- Install Flexisip and all dependencies
- Configure networking for TCP traffic
- Start the container
- Provision an endpoint
The build typically takes 5-8 minutes.
-
Access Your Flexisip Server
Once deployment completes, your Flexisip server will be accessible at:
- SIP Endpoint:
sip:example-app.klutch.sh:8000;transport=tcp - Admin Interface:
https://example-app.klutch.sh:8080(if HTTP admin is enabled)
- SIP Endpoint:
Post-Deployment Configuration
Testing SIP Connectivity
-
Test with SIP Client
Use a SIP client like Linphone, Zoiper, or MicroSIP to test connectivity:
-
Configure your SIP account:
- Username:
testuser@sip.example.com - Password: Your configured password
- Domain:
example-app.klutch.sh - Port:
8000 - Transport:
TCP
- Username:
-
Register the client
-
Check registration status in Flexisip logs
-
-
Verify Database Connection
Check that Flexisip is connecting to MySQL:
Terminal window # Connect to your MySQL databasemysql -h mysql-app.klutch.sh -P 8000 -u flexisip -p# Check registrations tableUSE sip;SELECT * FROM registrations;You should see active registrations from connected clients.
-
Monitor Logs
Access logs through your Klutch.sh dashboard or via the persistent volume to monitor:
- Registration requests
- Authentication attempts
- Routing decisions
- Error messages
Create SIP Accounts
You can create SIP accounts directly in the MySQL database:
-- Connect to your MySQL databaseUSE sip;
-- Create a new SIP accountINSERT INTO accounts (username, domain, password, algorithm, enabled)VALUES ( 'john', 'sip.example.com', SHA2('password123', 256), 'SHA256', TRUE);
-- Create another accountINSERT INTO accounts (username, domain, password, algorithm, enabled)VALUES ( 'jane', 'sip.example.com', SHA2('password456', 256), 'SHA256', TRUE);
-- View all accountsSELECT id, username, domain, enabled, created_at FROM accounts;Alternatively, you can build a web interface or API for user management.
Configure Custom Domain (Optional)
- Go to your Klutch.sh dashboard
- Navigate to your app’s settings
- Add your custom domain (e.g.,
sip.example.com) - Update your DNS records:
- Add A record or CNAME pointing to Klutch.sh
- Wait for DNS propagation (usually 5-60 minutes)
- Update
SIP_DOMAINenvironment variable to match
To use a custom domain for your SIP server:
Klutch.sh automatically provisions SSL certificates for custom domains.
Production Best Practices
Security Hardening
-
Strong Authentication
- Use SHA256 for password hashing (configured in
flexisip.conf) - Enforce strong password policies
- Change default admin credentials immediately
- Consider certificate-based authentication for trusted devices
- Use SHA256 for password hashing (configured in
-
TLS Encryption
Enable TLS for SIP signaling:
- Obtain valid TLS certificates (Let’s Encrypt, commercial CA)
- Upload certificates to
/etc/flexisip/tls/volume - Update
flexisip.conf:
[tls]tls-certificate-file=/etc/flexisip/tls/cert.pemtls-certificate-key-file=/etc/flexisip/tls/key.pemtls-ciphers=HIGH:!aNULL:!MD5- Use
sips:URI scheme for encrypted connections
-
Rate Limiting
Prevent abuse by configuring rate limits in
flexisip.conf:[module::DoSProtection]enabled=true# Maximum requests per second per IPmax-requests-per-second=10# Ban duration (seconds)ban-time=300 -
Firewall Rules
While Klutch.sh handles external routing, configure internal firewall rules:
- Allow only necessary ports (5060, 5061, 8080)
- Restrict admin interface access
- Implement IP whitelisting for known clients
-
Database Security
- Use strong database passwords
- Create dedicated database user with minimal privileges
- Enable MySQL SSL connections
- Regular database backups
Performance Optimization
-
Redis Caching
Enable Redis for registration caching to reduce database load:
[module::Registrar]redis-server-domain=${REDIS_HOST}redis-server-port=${REDIS_PORT}redis-auth-password=${REDIS_PASSWORD}# Cache TTL (seconds)redis-record-serializer=protobufBenefits:
- Faster registration lookups
- Reduced MySQL queries
- Better scalability
-
Connection Pooling
Configure MySQL connection pooling:
[module::Registrar]db-connection-string=db='sip' user='${MYSQL_USER}' password='${MYSQL_PASSWORD}' host='${MYSQL_HOST}' port='${MYSQL_PORT}' poolsize=10 -
Thread Configuration
Adjust thread count based on CPU cores:
[global]# Set to number of CPU coresthreads=4Monitor CPU usage and adjust accordingly.
-
Log Rotation
Implement log rotation to prevent disk space issues:
Terminal window # Add to docker-entrypoint.shcat > /etc/logrotate.d/flexisip << 'EOF'/var/log/flexisip/*.log {dailyrotate 14compressdelaycompressmissingoknotifemptycreate 0644 flexisip flexisip}EOF
Monitoring and Maintenance
-
Health Checks
Monitor Flexisip health through:
- HTTP Admin Interface: Check status at
https://example-app.klutch.sh:8080/status - Klutch.sh Dashboard: View container health and resource usage
- Log Analysis: Monitor error rates and performance metrics
- HTTP Admin Interface: Check status at
-
Key Metrics to Monitor
- Active Registrations: Number of currently registered users
- Call Setup Time: Time to establish SIP sessions
- Message Throughput: Messages per second
- Database Query Performance: MySQL response times
- Cache Hit Rate: Redis cache effectiveness
- Error Rates: Failed registrations, authentication failures
- Resource Usage: CPU, memory, disk, network
-
Alerting
Set up alerts for:
- High error rates
- Database connection failures
- Memory/CPU threshold breaches
- Disk space warnings
- Failed health checks
-
Backup Strategy
Regular backups of:
- MySQL database (user accounts, registrations)
- Flexisip configuration files
- TLS certificates and keys
- Push notification credentials
Automate backups through Klutch.sh’s volume backup features or external backup solutions.
Scaling Strategies
-
Vertical Scaling
Increase resources for a single Flexisip instance:
- Navigate to your app in Klutch.sh dashboard
- Adjust compute resources (CPU/Memory)
- Recommended for up to 1,000 concurrent users:
- Small: 1 CPU, 1GB RAM (100-500 users)
- Medium: 2 CPU, 2GB RAM (500-1,000 users)
- Large: 4 CPU, 4GB RAM (1,000-5,000 users)
-
Horizontal Scaling
For high availability and larger deployments:
- Deploy multiple Flexisip instances
- Use Flexisip’s built-in load balancing
- Configure cluster mode in
flexisip.conf:
[cluster]enabled=true# Cluster namecluster-name=flexisip-cluster# Other cluster nodescluster-nodes=flexisip-node-2.klutch.sh:5060 flexisip-node-3.klutch.sh:5060- Share Redis cache across all instances
- Use external load balancer if needed
-
Database Scaling
For large deployments:
- Use MySQL read replicas for registration lookups
- Implement connection pooling
- Partition registration tables by domain
- Consider dedicated presence database
Troubleshooting
Common Issues and Solutions
-
Problem: Flexisip container fails to start
Solution:
- Check Klutch.sh deployment logs for errors
- Verify all required environment variables are set
- Ensure MySQL and Redis are accessible
- Validate
flexisip.confsyntax withflexisip --check-config - Check entrypoint script permissions
-
Problem: Cannot register SIP clients
Solution:
Terminal window # Check Flexisip logstail -f /var/log/flexisip/flexisip.log# Verify TCP port 8000 is accessiblenc -zv example-app.klutch.sh 8000# Check database connectivitymysql -h $MYSQL_HOST -P $MYSQL_PORT -u $MYSQL_USER -p# Verify accounts tableSELECT * FROM sip.accounts WHERE username='testuser';Common causes:
- Incorrect SIP domain configuration
- Database connection issues
- Authentication failures (wrong password)
- Network connectivity problems
-
Problem: Authentication failures
Solution:
- Verify password hashing algorithm matches (SHA256)
- Check database credentials are correct
- Ensure SIP domain in client matches configuration
- Review authentication logs in Flexisip
-- Verify password hashSELECT username, domain, password, algorithm FROM sip.accounts WHERE username='testuser';-- Reset password if neededUPDATE sip.accounts SET password=SHA2('newpassword', 256) WHERE username='testuser'; -
Problem: Database connection errors
Solution:
- Verify MySQL is running and accessible
- Check hostname resolves:
ping mysql-app.klutch.sh - Test database connection:
Terminal window mysql -h $MYSQL_HOST -P $MYSQL_PORT -u $MYSQL_USER -p# If connection fails, check:# - MySQL is deployed and running# - Port 8000 is configured for TCP traffic# - Credentials are correct# - Database 'sip' exists -
Problem: Redis connection issues
Solution:
Terminal window # Test Redis connectivityredis-cli -h $REDIS_HOST -p $REDIS_PORT -a $REDIS_PASSWORD ping# Expected response: PONGIf Redis is not required, you can disable it:
[module::Registrar]# Comment out Redis configuration# redis-server-domain=${REDIS_HOST} -
Problem: High CPU or memory usage
Solution:
- Monitor active registrations and call volume
- Check for DOS attacks in logs
- Enable rate limiting (DoSProtection module)
- Increase thread count if CPU-bound
- Scale vertically (more resources) or horizontally (more instances)
- Optimize database queries
- Enable Redis caching
-
Problem: Push notifications not working
Solution:
- Verify APNs/FCM credentials are correctly configured
- Check certificate paths are correct
- Ensure certificates have not expired
- Review push notification module logs
- Test with simple notification first
[module::PushNotification]enabled=true# Verify pathsapns-certificate-path=/etc/flexisip/tls/apns-cert.pemapns-certificate-key-path=/etc/flexisip/tls/apns-key.pem
Debug Mode
To enable debug logging for troubleshooting:
[global]log-level=debugOr set environment variable:
LOG_LEVEL=debugWarning: Debug mode generates large log files. Use only for troubleshooting and disable in production.
Health Check Failures
- Verify Flexisip is running:
- Check configuration validity:
- Review recent logs for errors:
- Test SIP registration manually with sipclients
If health checks fail:
ps aux | grep flexisipflexisip --check-configtail -n 100 /var/log/flexisip/flexisip.logAdvanced Configuration
Push Notification Setup
-
Apple Push Notification Service (APNs)
- Obtain APNs certificate from Apple Developer Portal
- Convert to PEM format:
Terminal window openssl pkcs12 -in cert.p12 -out apns-cert.pem -nodes -clcertsopenssl pkcs12 -in cert.p12 -out apns-key.pem -nodes -nocerts- Upload to persistent volume at
/etc/flexisip/tls/ - Configure in
flexisip.conf:
[module::PushNotification]apns-certificate-path=/etc/flexisip/tls/apns-cert.pemapns-certificate-key-path=/etc/flexisip/tls/apns-key.pem -
Firebase Cloud Messaging (FCM)
- Download service account JSON from Firebase Console
- Upload to
/etc/flexisip/fcm-service-account.json - Configure in
flexisip.conf:
[module::PushNotification]firebase-service-account-file=/etc/flexisip/fcm-service-account.json
Media Relay (TURN/STUN)
stun.l.google.com:19302stun1.l.google.com:19302stun2.l.google.com:19302
For NAT traversal and media routing:
[module::MediaRelay]enabled=true# STUN server (free public servers available)stun-server=stun.l.google.com:19302# TURN server (deploy your own or use service)turn-server=turn.example.com:3478turn-username=turnuserturn-password=turnpassword# TURN transportturn-transport=udpPublic STUN servers:
For production, deploy your own TURN server (coturn is popular).
Presence Server
Enable presence for showing user availability:
[module::Presence]enabled=truepresence-server=sip:presence.example.com# Use Redis for presence datadb-implementation=redisredis-server-domain=${REDIS_HOST}redis-server-port=${REDIS_PORT}# Presence expiration time (seconds)presence-expires=3600Conference Server
For multi-party conferencing:
[module::Conference]enabled=true# Conference URI formatconference-uri=sip:conf@example.com# Maximum participants per conferencemax-participants=10# Audio mixingenable-audio-mixing=trueLoad Balancing
Configure Flexisip as a load balancer:
[module::Forward]enabled=true# Backend SIP serversroutes=sip:backend1.example.com:5060;transport=tcp sip:backend2.example.com:5060;transport=tcp# Load balancing algorithm: round-robin, hash, least-connectionsroute-selection=round-robinIntegration Examples
SIP Client Configuration
Linphone (Desktop/Mobile):
Username: johnPassword: password123Domain: example-app.klutch.shTransport: TCPPort: 8000Zoiper:
Account Type: SIPUsername: janeDomain: example-app.klutch.sh:8000Password: password456Outbound Proxy: example-app.klutch.sh:8000Transport: TCPAsterisk Integration
Connect Asterisk PBX to Flexisip:
; In Asterisk pjsip.conf[flexisip-trunk]type=endpointcontext=from-flexisipdisallow=allallow=ulawallow=alawtransport=transport-tcpaors=flexisip-aor
[flexisip-aor]type=aorcontact=sip:example-app.klutch.sh:8000;transport=tcp
[flexisip-identify]type=identifyendpoint=flexisip-trunkmatch=example-app.klutch.shWebRTC Integration
For web-based calling:
// JavaScript SIP client (JsSIP example)const socket = new JsSIP.WebSocketInterface('wss://example-app.klutch.sh:5062');const configuration = { sockets: [socket], uri: 'sip:john@sip.example.com', password: 'password123', display_name: 'John Doe'};
const ua = new JsSIP.UA(configuration);ua.start();
// Make a callua.call('sip:jane@sip.example.com', { mediaConstraints: { audio: true, video: true }});Additional Resources
-
Official Documentation: Flexisip Wiki
-
GitHub Repository: Flexisip on GitHub
-
SIP Protocol: RFC 3261
-
Linphone SDK: Linphone Project
-
MySQL Documentation: MySQL Docs
-
Redis Documentation: Redis Docs
-
Docker Documentation: Docker Docs
-
TURN Server (coturn): coturn on GitHub
-
Klutch.sh Support: For platform-specific questions, visit the Klutch.sh documentation
Production Checklist
Before going live with your Flexisip deployment, verify:
- Dockerfile builds successfully
- MySQL database deployed and accessible
- Redis cache deployed (optional but recommended)
- Environment variables configured correctly
- Persistent volumes attached for logs and data
- TCP traffic configured on port 8000 → 5060
- SIP domain configured correctly
- TLS certificates installed and valid
- Strong admin password set
- Database credentials are secure
- SIP accounts created and tested
- Client registration successful
- Call routing working correctly
- Push notifications configured (if using mobile)
- Rate limiting enabled (DoS protection)
- Log rotation configured
- Monitoring and alerting setup
- Backup strategy implemented
- Health checks passing consistently
- Performance tested under expected load
- Security audit completed
- Documentation updated for team
- Disaster recovery plan in place
Conclusion
Deploying Flexisip on Klutch.sh gives you a production-ready SIP server with enterprise-grade features for VoIP and real-time communications. The combination of Flexisip’s robust architecture and Klutch.sh’s scalable infrastructure makes it an ideal solution for building reliable telephony systems.
With this guide, you now have:
- A production-ready Dockerfile for Flexisip
- Complete configuration for MySQL and Redis integration
- TCP traffic setup for SIP signaling
- Persistent storage for logs and data
- Security best practices for VoIP systems
- Performance optimization strategies
- Comprehensive troubleshooting solutions
- Advanced features like push notifications and load balancing
Start building your VoIP infrastructure with the reliability of Flexisip and the simplicity of Klutch.sh. Your SIP server is ready to handle millions of calls and messages with confidence.
For questions or issues specific to Klutch.sh deployments, refer to the platform documentation or contact support. Happy calling!