DjangoPBX Replica Installation¶
For high availability you may wish to have a replica instance of DjangoPBX, this will allow the FreeSWITCHes to get their configuration and dialplans if the primary instance of DjangoPBX goes down.
Generally, DjangoPBX Replicas will be created by simply cloning an existing DjangoPBX primary and then making some minor modifications. However, if you do not wish to clone there is an option in the DjangoPBX installer that will allow you to build a replica without performing any of the database actions such as creating a super user or loading any default configuration. The configuration option is called “install_djangopbx_as_replica”
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_djangopbx_as_replica="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.
Copy the .ssh/rsa_id and .ssh/rsa_id.pub key air from the django-pbx user on the primary DjangoPBX to the .ssh directory of the django-pbx user on this replica.
Edit ~/pbx/pbx/settings_local.py
Add the private LAN address for this machine to ALLOWED_HOSTS Be sure to enable the Replica database connection and also the database router. This will allow the use of the replica database for read operations. 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
172.20.20.106 dpbx1-r1.djangopbx.com dpbx1-r1
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.
Disable the PBX event receiver, this is only required on the primary instance. (It can be re-enabled if the primary instance will be down for any length of time)
systemctl disable pbx_event_receiver.target
Reboot.