Skip to content

jishanalibd/universal-sip-websocket-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Universal SIP WebSocket Proxy

A production-ready SIP-over-WebSocket (WSS) provider model that enables users to connect from browsers or web applications using their own SIP credentials.

🎯 Overview

This project provides a universal SIP WebSocket gateway that allows web-based SIP clients (like Browser-Phone, JsSIP, SIP.js) to connect to any backend SIP server without being locked into a specific PBX.

User Flow

  1. User visits your web app (e.g., https://phone.yourdomain.com)
  2. They enter their SIP credentials:
    • SIP domain: sip.mycompany.com
    • Username: user123
    • Password: secret
  3. Browser connects via wss://sipproxy.yourdomain.com:443
  4. Kamailio proxy accepts WSS β†’ converts to standard SIP UDP/TCP β†’ forwards to their SIP server
  5. Media flows through rtpengine for WebRTC compatibility

🧩 Components

Component Role Notes
Kamailio WSS proxy + TLS terminator Handles SIP over WebSocket
rtpengine Media relay Converts SRTP ↔ RTP for WebRTC
Let's Encrypt TLS certificates Auto-renew for secure WSS
Browser Phone UI Web client (optional) JsSIP or SIP.js based
Any SIP server Backend destination Receives REGISTER, INVITE

πŸ“‹ Prerequisites

  • Ubuntu 22.04 or 24.04 LTS
  • Domain name pointing to your server (e.g., sipproxy.yourdomain.com)
  • Root or sudo access
  • Ports: 80, 443, 8080, 5060-5061 (UDP/TCP), 10000-20000 (UDP for RTP)

πŸš€ Quick Start

1. Clone the repository

git clone https://github.com/jishanalibd/universal-sip-websocket-proxy.git
cd universal-sip-websocket-proxy

2. Run the installation script

sudo bash scripts/install.sh

This will:

  • Install Kamailio and rtpengine
  • Configure firewall rules
  • Set up systemd services
  • Install required dependencies

3. Configure your domain

Edit /etc/kamailio/kamailio.cfg and update:

#!define DOMAIN "sipproxy.yourdomain.com"

4. Get SSL certificates

sudo bash scripts/setup-ssl.sh sipproxy.yourdomain.com [email protected]

5. Start services

sudo systemctl start kamailio
sudo systemctl start rtpengine

πŸ“– Detailed Installation

See docs/INSTALLATION.md for step-by-step installation instructions.

For quick command reference, see docs/QUICK-REFERENCE.md.

πŸ”§ Configuration

Kamailio Configuration

The main Kamailio configuration is located at:

  • /etc/kamailio/kamailio.cfg - Main configuration
  • /etc/kamailio/tls.cfg - TLS settings

rtpengine Configuration

Configuration file: /etc/rtpengine/rtpengine.conf

Key settings:

  • Interface for RTP relay
  • Port ranges
  • Kernel forwarding

🌐 Client Configuration

Browser-Phone Example

var config = {
  websocket_proxy_url: 'wss://sipproxy.yourdomain.com:443',
  domain: 'sip.mycompany.com',  // User's actual SIP domain
  username: 'user123',
  password: 'secret',
  display_name: 'John Doe'
};

JsSIP Example

var socket = new JsSIP.WebSocketInterface('wss://sipproxy.yourdomain.com:443');
var configuration = {
  sockets: [socket],
  uri: 'sip:[email protected]',
  password: 'secret'
};

var ua = new JsSIP.UA(configuration);
ua.start();

See docs/CLIENT-EXAMPLES.md for more examples.

πŸ”’ Security

  • TLS 1.2+ required for WSS connections
  • Automatic certificate renewal via Let's Encrypt
  • SIP digest authentication
  • Rate limiting and anti-flood protection
  • IP-based access control (optional)

πŸ› Troubleshooting

See docs/TROUBLESHOOTING.md for common issues and solutions.

Quick Debug

# Check Kamailio logs
sudo tail -f /var/log/syslog | grep kamailio

# Check rtpengine logs
sudo journalctl -u rtpengine -f

# Test WebSocket connection
wscat -c wss://sipproxy.yourdomain.com:443

Test Client

A ready-to-use web-based test client is included in the examples/ directory:

# Serve the test client
cd examples
python3 -m http.server 8000
# Open http://localhost:8000/test-client.html in your browser

The test client allows you to:

  • Connect to your WebSocket proxy
  • Register with any SIP server
  • Make and receive calls
  • View real-time logs

See examples/README.md for more details.

πŸ“ Project Structure

.
β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ kamailio/           # Kamailio configuration files
β”‚   β”œβ”€β”€ rtpengine/          # rtpengine configuration
β”‚   └── systemd/            # systemd service files
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ install.sh          # Main installation script
β”‚   β”œβ”€β”€ setup-ssl.sh        # SSL certificate setup
β”‚   └── firewall.sh         # Firewall configuration
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ INSTALLATION.md     # Detailed installation guide
β”‚   β”œβ”€β”€ CLIENT-EXAMPLES.md  # Client configuration examples
β”‚   └── TROUBLESHOOTING.md  # Troubleshooting guide
β”œβ”€β”€ examples/
β”‚   β”œβ”€β”€ test-client.html    # Web-based test client
β”‚   └── README.md           # Examples documentation
└── README.md

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“„ License

MIT License - see LICENSE file for details.

πŸ”— Related Projects

πŸ“ž Support

For issues and questions:

⚑ Performance Tips

  • Use UDP for SIP signaling when possible
  • Configure kernel RTP forwarding in rtpengine
  • Enable Kamailio's shared memory optimizations
  • Use SSD storage for better I/O performance
  • Consider using multiple rtpengine instances for load balancing

πŸŽ“ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         WSS (443)        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Browser   │◄─────────────────────────►│   Kamailio   β”‚
β”‚  (JsSIP)    β”‚                           β”‚  WSS Proxy   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                           β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
      β–²                                          β”‚
      β”‚                                          β”‚ SIP UDP/TCP
      β”‚ SRTP                                     β”‚
      β”‚                                          β–Ό
β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  rtpengine  │◄─────────────────────────►│  Backend SIP β”‚
β”‚ Media Relay β”‚         RTP              β”‚    Server    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The proxy acts as a transparent gateway, forwarding SIP messages to any backend SIP server while handling WebSocket/TLS on the client side and RTP/SRTP media conversion.

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages