Skip to main content
All CollectionsGetting Started
Deploy a FreePBX server in a docker host
Deploy a FreePBX server in a docker host

How to install and connect FreePBX to Odoo using OdooPBX modules.

Max Li avatar
Written by Max Li
Updated over 4 months ago

Introduction

In this article we are going to install the FreePBX server and connect it to an Odoo instance and go over all the settings that need to be made for this. In general terms, the sequence of actions is as follows:

  • Prepare a server host and install Docker on it.

  • Prepare a docker-compose.yml file with description of services.

  • Prepare hostnames for the Let's encrypt certificates.

  • Install the Asterisk Plus Agent middleware.

  • Configure it all together.

If you prefer the original way of installing FreePBX using an image from Sangoma, that is also a choice. It's just that we are most comfortable using docker and we will use the izpbx build. Anyway, all other steps are the same regardless of your choice of installation type.

Here is the video recorded following this guide:

FreePBX Installation

Prepare the host system

We are going to use Ubuntu 24.04 and install the docker package as described in the official documentation here. Next we should create the following docker-compose.yml file in /srv/odoopbx folder:

volumes:                                                                                                                                                      
srv:
freepbx_db:
freepbx_data:

services:
agent:
image: odoopbx/agent:latest
restart: unless-stopped
container_name: agent
privileged: True
network_mode: host
command: https://demo.odoopbx.com
environment:
- LOG_LEVEL=INFO
volumes:
- srv:/srv
- freepbx_data:/data/
- ./monitor/:/var/spool/asterisk

freepbx-db:
image: mariadb:10.6.10
container_name: freepbx-db
command: --sql-mode=ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
restart: unless-stopped
env_file:
- freepbx.env
environment:
- EDITOR
volumes:
- freepbx_db:/var/lib/mysql
ports:
- 127.0.0.1:3306:3306/tcp

freepbx:
image: izdock/izpbx-asterisk:latest
container_name: freepbx
hostname: ${APP_FQDN:-freepbx}
privileged: true
network_mode: host
cap_add:
- NET_ADMIN
restart: unless-stopped
depends_on:
- freepbx-db
env_file:
- freepbx.env
volumes:
- freepbx_data:/data/
ulimits:
nofile:
soft: 8192
hard: 32768

networks:
default:
driver: bridge
ipam:
config:
- subnet: 172.172.0.0/16

We should also create a freepbx.env file with the installation settings. Here is an example:

APP_FQDN=freepbx-demo.odoopbx.com
APP_DATA=/data
PHONEBOOK_ENABLED=false
MYSQL_PASSWORD=change-me-1111
MYSQL_ROOT_PASSWORD=change-me-1111
MYSQL_SERVER=127.0.0.1
TZ=Europe/Tallinn
HTTPD_HTTPS_ENABLED=true
HTTPD_REDIRECT_HTTP_TO_HTTPS=true
LETSENCRYPT_ENABLED=true
LETSENCRYPT_COUNTRY_CODE=EE
LETSENCRYPT_COUNTRY_STATE=Tallin
[email protected]
FAIL2BAN_ENABLED=true
FAIL2BAN_ASTERISK_ENABLED=true
FOP2_ENABLED=false
ZABBIX_ENABLED=false
[email protected]
[email protected]

For all possible options see izpbx github page.

We define server's hostname, Let's encrypt data for certificates. SMTP_MAIL_FROM must be a valid regisyered in Letsencrypt email address.

Finally, we should create a monitor folder and put a synlink there in order to enable the Agent to access the recording under the correct path:

mkdir /srv/odoopbx/monitor
cd /srv/odoopbx/monitor
ln -s /data/var/spool/asterisk/monitor .

The symlink seems to be broken at the docker host level but inside the Agent container it points to the existing folder /data/var/spool/asterisk/monitor.

Now we can start freepbx attached to the terminal to check how it's initialized:

systemctl enable --now docker
docker compose up freepbx

FreePBX configuration

Certificates

In order to use WebRTC Odoo phone we need to have the certificates. We need to have valid default certificate under Admin => Certificate Management:

SIP Channel Driver

Make sure that the default SIP driver is PJSIP, check it in Settings => Advanced Settings => SIP Channel Driver:

STUN Server Address

Navigate to Settings => Asterisk SIP Settings => General SIP Settings and add a STUN server there (we use stun.l.google.com:19302):

Enable WSS Transport

Navigate to Settings => Asterisk SIP Settings => SIP Settings [chan_pjsip] and enable wss:

The Agent middleware

Agent installation

The Agent installation is covered in this article: The Agent middleware. As we use a FreePBX server, we will create a manager user under Settings => Asterisk Manager Users:

This manager user must be also created in Odoo:

After configuring the manager user for the Agent we now set the Odoo URL in the Agent service in the docker-compose:

And now run the Agent:

docker compose up -d agent

Check the output:

docker compose logs agent

Now everything is connected.

Create a phone user

Create a WebRTC user in FreePBX

Select Add New SIP [chan_pjsip] Extension. Then configure the following options in the Advanced tab:

  • Transport: WSS

  • Enable AVPF: Yes

  • Enable ICE Support: Yes

  • Enable rtcp Mux: Yes

  • Media use received transport: yes

  • RTP Symmetric: Yes

  • Force rport: Yes

  • Enable WebRTC Defaults: Yes

  • Media Encryption: TDTL-SRTP

  • Enable DTLS: Yes

  • Auto Generate Certificates: Yes

  • DTLS Verify: Fingerprint

  • DTLS Setup: Act/Pass

Next we need to create a PBX User in Odoo.

Odoo configuration

WebRTC Phone settings

We need to setup WebRTC Phone settings under PBX => Settings => General => WebRTPC Phone tab.

Also we need to enable Generate SIP peers option in order to be able to supply WebRTC channel password for the user's phone (in PBX => Settings => Server => SIP Users tab):

Create an OdooPBX user

Next we need to create an OdooPBX user mapping in PBX => Application => Users:

Now reload the user interface in order to initialize the WebRTC phone.

Configure Odoo CallerID lookup source

Finally, in order to have a callerID name set from Odoo, use the following configuration in FreePBX Admin => CallerID Lookup Sources. Use asterisk_plus/get_caller_name as the Path option and number=[NUMBER] as the Query:

That's all folks!

Did this answer your question?