DjangoPBX Installation

Have a domain name ready for this step.

Add ARP filter because we have two NICs:

echo "net.ipv4.conf.all.arp_filter = 1" >> /etc/sysctl.conf

Download the installer:

mkdir -p /usr/src/djangopbx-install
cd /usr/src/djangopbx-install
wget https://codeberg.org/djangopbx/djangopbx-install.sh/raw/branch/main/install.sh
nano install.sh

Make the following changes to the configuration section:

set rabbitmq_password to the value generated by the AMQP Broker installer.
set domain_name and default_domain_name to your requirements
# Scaling and Clustering Options
freeswitch_core_in_postgres="no"
use_rabbitmq_broker="yes"
install_rabbitmq_local="no"
install_postgresql_local="no"
install_freeswitch_local="no"
install_djangopbx_local="yes"
install_remote_event_receiver="no"

Run the installer:

chmod +x install.sh
./install.sh

Once the installer has completed successfully complete the following steps.

Log in as the django-pbx user (su - django-pbx) Generate an ssh key pair:

ssh-keygen

Leave passphrase empty, just press Enter for the passphrase and its check.

Now copy your django-pbx public key to your other servers:

ssh-copy-id -i ~/.ssh/id_rsa.pub django-pbx@<your filestore private LAN IP>
ssh-copy-id -i ~/.ssh/id_rsa.pub django-pbx@<your freeswitch private LAN IP> (repeat for each FreeSWITCH)

Next, we need to change the call recording method. The monolithic, single machine install uses the local filing system to store call recordings, but in a clustered arrangement we use the http_cache method.

Changing the symbolic link below achieves this.
Navigate to ~/pbx/dialplans/resources/switch/conf/dialplans-enabled
delete the symlink 050_user_record.xml
add a new symlink from ~/pbx/dialplans/resources/switch/conf/dialplans-available/050_user_record_http.xml

Edit ~/pbx/pbx/settings_local.py

Add the private LAN address for this machine to ALLOWED_HOSTS Also edit/add the following settings:

MEDIA_ROOT = '/files/media'
PBX_FREESWITCHES = [<the unqualified host names of all your FreeSWITCH servers, e.g. 'fsw1', 'fsw2'>]
PBX_FILESTORES = [<the unqualified host names of all your file stores, e.g. 'sftp1' >]
PBX_USE_LOCAL_EVENT_SOCKET = False
PBX_USE_LOCAL_FILE_STORAGE = False
PBX_FREESWITCH_LOCAL = False
PBX_SERVER_URL = 'http://<private LAN IP of your DjangoPBX>
PBX_XMLH_ALLOWED_ADDRESSES = ['127.0.0.1/32', '::1/128', <add your FreeSWITCH IP addresses>]
PBX_CDRH_ALLOWED_ADDRESSES = ['127.0.0.1/32', '::1/128', <add your FreeSWITCH IP addresses>]
PBX_HTTAPI_ALLOWED_ADDRESSES = ['127.0.0.1/32', '::1/128', <add your FreeSWITCH IP addresses>]

Edit /etc/hosts and add names and private LAN IP addresses of the AMQP Broker and Filestores and the public IPs of the FreeSWITCHes eg:

127.0.0.1      localhost
195.xx.xx.146  dpbx1.djangopbx.com     dpbx1
172.20.20.102  amqp1
172.20.20.103  sftp1
172.20.20.144  fsw1
172.20.20.145  fsw2

Edit /etc/nftables.conf

add your FreeSWITCHes or Private LAN subnet to the IPv4_white_list add 8008 and 8009 to your private_tcp_services

Edit /etc/uwsgi/apps-available/fs_config.ini and change 127.0.0.1 for the private LAN address of this machine.

Edit /etc/nginx/sites-available/djangopbx and change 127.0.0.1:8009 for the private LAN address of this machine, leave the port (:8009) part unchanged.

In the application Admin pages edit…

Home > Dialplan Manager > Dialplans

Edit global-variables,
set the category to Default Modified to prevent it from being overwritten.
set the exported channel variables in the extension XML as follows:
pbx_httapi_url=<private LAN address of your DjangoPBX>
pbx_call_recording_url=<private LAN address of your Filestore>
pbx_recording_url=<private LAN address of your Filestore>
pbx_play_recording_url=<private LAN address of your Filestore>

for example:

<extension name="global-variables" continue="true" uuid="156a39ba-35f4-4bd0-aee9-bd48f9376b9d">
 <condition field="" expression="">
   <action application="set" data="RFC2822_DATE=${strftime(%a, %d %b %Y %T %z)}"/>
   <action application="export" data="pbx_call_recording_url=http://172.20.20.103:80" inline="true"/>
   <action application="export" data="pbx_recording_url=http://172.20.20.103:80" inline="true"/>
   <action application="export" data="pbx_play_recording_url=http://172.20.20.103:80" inline="true"/>
 </condition>
</extension>

If you have PosgreSQL installed locally, add your FreeSWITCH hosts to /etc/postgresql/15/main/pg_hba.conf otherwise add them in your stand alone PostgreSQL instances.

# IPv4 freeswitch private LAN connections
host    all             all             10.xx.xx.xx/32          scram-sha-256
host    all             all             10.xx.xx.xx/32          scram-sha-256

If you have not installed PostgreSQL locally, then you must edit the unit files for the event receiver to remove the startup dependency on postgresql.service:

Edit /lib/systemd/system/pbx_event_receiver.target and remove postgresql.service from both the “Requires” and “After” lines.
Edit /lib/systemd/system/pbx_event_receiver@.service and remove postgresql.service from both the “Requires” and “After” lines.

Then execute:

systemctl daemon-reload