Introduction
Many have asked us why Sonata Suite have a different login than VitalPBX and you have to enter these applications separately. Below is the answer.
Well, VitalPBX from its beginnings was thought of as a Modular App with the possibility of installing certain modules on independent servers with the aim of lightening the load on the main server and also for security reasons.
The advantages of this model is that each module can have its own administrator, for example in certain cases it is not desirable for a Call Center Agent/Supervisor to have access to the VitalPBX server, and as we know a Call Center uses a lot of Sonata Switchboard, for which is a good practice to install this module on a separate server if we are going to require a lot of this resource.
In the case of Sonata Stats, generating reports sometimes requires a lot of server resources when there are many Agents/Queues to process, in these cases it is a good practice to install Sonata Stats on a separate server.
Initial Settings
The first thing we will do is install VitalPBX on both Servers. This will make configuration much easier. We will call these servers as follows:
- Server 1 (VitalPBX Server)
- Server 2 (App Server)
To see the steps how to install VitalPBX 4 we recommend the following Blog:
https://vitalpbx.com/blog/install-vitalpbx-4-in-debian/
On both Servers, install Sonata Suite App that we want to have remotely.
Server 1 Configurations
Go to /etc/mysql/mariadb.conf.d and edit the 50-server.cnf file to allow external connections to the database.
cd /etc/mysql/mariadb.conf.d/ nano 50-server.cnf |
Change
bind-address = 127.0.0.1 |
by
bind-address = 0.0.0.0 |
Or if you want more security add only the IP of the Server 2
bind-address = 127.0.0.1,IP_SERVER2 |
and restart MariaDB
systemctl restart mariadb |
Now we have to enable access to port 3306 for which we must go to the VitalPBX GUI and in ADMIN/Firewall/Services create the MariaDB Service with TCP port 3306.
Then go to Rules and create the Rule with the previously created Service and if we want to be more strict, only allow connections from the IP of Server 2 only.
We also recommend at the Firewall level to whitelist the IP of Server 2, for which we go to ADMIN/Firewall/Access Control and press +Whitelist an IP.
Finally, we must go to ADMIN/Admin/Application Keys and create a key that includes all the Tenants (–Any Tenant–) and copy it, we will use it later in the configuration of Server 2.
Installing Sonata Switchboard
Install the Sonata Switchboard from the VitalPBX interface. Remember that on Server 1 the Sonata Switchboard must also be installed.
Now we go to Server 1 and copy the MariaDB connection credentials and also give privileges with these credentials so that they can connect from Server 2.
Sonata Switchboard Credentials
Go to /etc/switchboard/ and edit the settings.conf file.
cd /etc/switchboard/ nano settings.conf |
Copy Sonata Switchboard Database Credentials.
[pbx-api] host=127.0.0.1 [app] database=astboard port=3306 host=localhost username=astboard password=jEjKz7JLRhjvD4eA |
With this information, enter MariaDB and create Server 2 access to these databases.
mysql -uroot |
grant all privileges on astboard.* to “astboard”@”207.246.70.193” identified by “jEjKz7JLRhjvD4eA”; |
FLUSH PRIVILEGES; exit |
Now we go back to Server 2 and set up the MariaDB connection credentials we got from configuring Server 1. We are also going to change the DB_HOST to the IP of Server 1.
Go to /etc/switchboard and edit the settings.conf file.
cd /etc/switchboard/ nano settings.conf |
[pbx-api] host=45.32.164.219 token=6b6d7233f53308594653164a609d2b52 [app] database=astboard host=45.32.164.219 username=astboard password=jEjKz7JLRhjvD4eA |
Remember that Sonata Switchboard is connected to the Asterisk AMI to be able to view the events in real time, for which it is necessary to configure a connection to the AMI remotely, for which we go on Server 1 to create a new AMI user.
But first you have to allow this connection remotely in the Firewall, so we go to ADMIN/Firewall/Services and create the service.
Now we are going to create the rule that will use this service.
Now we proceed to create the new AMI user in SETTINGS/PBX Settings/Asterisk Manager Users.
Now that we have created the new AMI user on Server 1, we go to Server 2 and in the /usr/share/vitalpbx/monitor folder we edit the config.ini file.
cd /usr/share/vitalpbx/monitor nano config.ini |
And in the [Asterisk] section we configure the AMI credentials that we created previously in the same way that we configured the IP of Server 1.
[asterisk] username=switchboard password=Xn75CFbVfjRg71v host=45.32.164.219 port=5038 |
Once this is done, we restart the vpbx_monitor service.
systemctl restart vpbx-monitor.service |
Now we reload our Sonata Switchboard, and everything should work fine. We have already installed Sonata Switchboard on an External Server.
If for some reason it doesn’t connect, it could be that the MariaDB credentials are not correct. In some cases, it is necessary to restart MariaDB on Server 1.
To test if the credentials are correct, we execute the following command on Server 2.
mysql -uastboard -h 45.32.164.219 -pjEjKz7JLRhjvD4eA |
Installing Sonata Stats
Install Sonata Stats from the VitalPBX interface. We must remember that in Server 1 the Sonata Stats must also be installed locally, that is, when we run the configuration Wizard, we will choose localhost as shown below.
Now in the installation of Sonata Stats on Server 2 we must enter the IP or domain of Server 1 as well as the API Key that we created and copied previously.
Now we go to Server 1 and copy the MariaDB connection credentials and also give privileges with these credentials so that they can connect from Server 2.
Sonata Stats Credentials
Go to /usr/share/queues-stats/backend and edit the .env file.
cd /usr/share/queues-stats/backend/ nano .env |
Copy the credentials from the Sonata Stats database.
DB_HOST=127.0.0.1 DB_USERNAME=stats DB_DATABASE=sonata_stats DB_PASSWORD=cJt1Cez2vjQk6QXt0gPJ |
And from the Asterisk database.
DB_ASTERISK_HOST=127.0.0.1 DB_ASTERISK_DATABASE=asterisk DB_ASTERISK_USERNAME=stats DB_ASTERISK_PASSWORD=cJt1Cez2vjQk6QXt0gPJ |
With this information, enter MariaDB and create Server 2 access to these databases.
mysql -uroot |
grant all privileges on sonata_stats.* to “stats”@”207.246.70.193” identified by “cJt1Cez2vjQk6QXt0gPJ”; |
grant all privileges on asterisk.* to “stats”@”207.246.70.193” identified by “cJt1Cez2vjQk6QXt0gPJ”; |
FLUSH PRIVILEGES; exit |
Now we go back to Server 2 and configure the MariaDB connection credentials that we got from the configuration of Server 1. We are also going to change the DB_HOST to the IP of Server 1.
Go to /usr/share/queues-stats/backend and edit the .env file.
cd /usr/share/queues-stats/backend/ nano .env |
In the Stats database we should have something like this. Only DB_HOST and DB_PASSWORD is changed.
DB_HOST= 45.32.164.219 DB_USERNAME=stats DB_DATABASE=sonata_stats DB_PASSWORD= cJt1Cez2vjQk6QXt0gPJ |
And from the Asterisk database.
DB_ASTERISK_HOST=45.32.164.219 DB_ASTERISK_DATABASE=asterisk DB_ASTERISK_USERNAME=stats DB_ASTERISK_PASSWORD= cJt1Cez2vjQk6QXt0gPJ |
Now we reload our Sonata Stats and everything should work fine. We have already installed Sonata Stats on an External Server.
Installing Sonata Recordings
Install Sonata Recordings from the VitalPBX interface. You must remember that Sonata Recordings must also be installed on Server 1.
Now we go to Server 1 and copy the MariaDB connection credentials and also give privileges with these credentials so that they can connect from Server 2.
Sonata Recordings credentials
Go to /etc/rec-manager and edit the settings.conf file.
cd /etc/rec-manager/ nano settings.conf |
Copy the credentials from the Sonata Recordings database.
[pbx-api] host=127.0.0.1 [app] database=telerec port=3306 host=localhost username=telerec password=telerec |
With this information, enter MariaDB and create Server 2 access to these databases.
mysql -uroot |
grant all privileges on telerec.* to “telerec”@”207.246.70.193” identified by “telerec”; |
grant all privileges on asterisk.* to “telerec”@”207.246.70.193” identified by “telerec”; |
FLUSH PRIVILEGES; exit |
Now we go back to Server 2 and configure the MariaDB connection credentials that we got from the configuration of Server 1. We are also going to change the DB_HOST to the IP of Server 1.
Go to /etc/rec-manager and edit the settings.conf file.
cd /etc/rec-manager/ nano settings.conf |
[pbx-api] host=45.32.164.219 token=6b6d7233f53308594653164a609d2b52 [app] database=telerec port=3306 host=45.32.164.219 username=telerec password=telerec |
Now we reload our Sonata Recordings, and everything should work fine. We have already installed Sonata Recordings on an External Server.
If for some reason it doesn’t connect, it could be that the MariaDB credentials are not correct. In some cases, it is necessary to restart MariaDB on Server 1.
To test if the credentials are correct, we execute the following command on Server 2.
mysql -utelerec -h 45.32.164.219 -ptelerec |
Share Recordings Folder
In the case of Sonata Recordings, it is necessary to access the recording files remotely, which is why the following procedure is necessary.
We are going to prepare Server 1 to share the folder where the recordings are stored by installing the following.
apt install nfs-kernel-server |
Now we will allow a client to access the folder /var/spool/asterisk/monitor/
chown nobody:nogroup /var/spool/asterisk/monitor/ chmod 777 /var/spool/asterisk/monitor/ |
Now it is necessary to grant access permissions to Server 2, for this we must modify the /etc/exports file.
nano /etc/exports |
/var/spool/asterisk/monitor IP_SERVER2(rw,sync,no_subtree_check) |
exportfs -a systemctl restart nfs-kernel-server |
Now we go to Server 2 to configure the Client part. For which we install the following.
apt install nfs-common |
We create a folder where the shared folder will be mounted on Server 1.
mkdir /nfs/recordings/ |
Now we delete the folder /var/spool/asterisk/monitor
rm -rf /var/spool/asterisk/monitor/ |
Since we no longer have the monitor folder where VitalPBX saved the recordings on Server 2, we proceed to create a virtual link.
cd /var/spool/asterisk/ ln -s /nfs/recordings/ monitor |
Next, we are going to mount the shared directory.
mount IP_SERVER1:/var/spool/asterisk/monitor/ /nfs/recordings/ |
And to mount it permanently we must configure the file /est/fstab
nano /etc/fstab |
IP_SERVER1:/var/spool/asterisk/monitor /nfs/recordings nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0 |
Installing Sonata Billing
Install Sonata Billing from the VitalPBX interface. It must be remembered that Sonata Billing must already be installed on Server 1.
Now we go to Server 1 and copy the MariaDB connection credentials and also give privileges with these credentials so that they can connect from Server 2.
Sonata Billing credentials
Go to /etc/billing and edit the settings.conf file.
cd /etc/billing/ nano settings.conf |
Copy the credentials from the Sonata Billing database.
[pbx-api] host=127.0.0.1 [app] database=sonata_billing port=3306 host=localhost username=sonata_ billing password=j3jK27JLRh9vD4eA |
With this information, enter MariaDB and create Server 2 access to these databases.
mysql -uroot |
grant all privileges on sonata_billing.* to “sonata_billing”@”207.246.70.193” identified by “j3jK27JLRh9vD4eA”; |
grant all privileges on asterisk.* to “sonata_billing”@”207.246.70.193″ identified by ” j3jK27JLRh9vD4eA”; |
FLUSH PRIVILEGES; exit |
Now we go back to Server 2 and configure the MariaDB connection credentials that we got from the configuration of Server 1. We are also going to change the DB_HOST to the IP of Server 1.
Go to /etc/billing and edit the settings.conf file
cd /etc/billing/ nano settings.conf |
[pbx-api] host=45.32.164.219 token=6b6d7233f53308594653164a609d2b52 [app] database=sonata_billing port=3306 host=45.32.164.219 username=sonata_billing password=j3jK27JLRh9vD4eA |
Now we recharge our Sonata Billing and everything should work fine. We have already installed Sonata Billing on an External Server.
If for some reason it doesn’t connect, it could be that the MariaDB credentials are not correct. In some cases it is necessary to restart MariaDB on Server 1.
To test if the credentials are correct, we execute the following command on Server 2.
mysql -usonata_billing -h 45.32.164.219 -pj3jK27JLRh9vD4eA |
Installing Sonata Dialer
In order to use the Softphone that Sonata Dialer brings, it is necessary to have VitXi installed and configured on both servers. Therefore, you can go to the Blog on how to install VitXi on an external server at the following link:
https://vitalpbx.com/blog/how-to-install-vitxi-on-an-external-server/
Install Sonata Dialer from the VitalPBX interface. We must remember that on Server 1 the Sonata Dialer must also be installed locally, that is, when we run the configuration Wizard, we will choose localhost as shown below.
Now in the installation of Sonata Dialer in Server 2 we must enter the IP or valid FQDN domain (If we are going to use the integrated Softphone) of Server 1 as well as the API Key that we created and copied previously.
Now we go to Server 1 and copy the MariaDB connection credentials and also give privileges with these credentials so that they can connect from Server 2.
Sonata Dialer Credentials
Go to /usr/share/dialer/backend and edit the .env file.
cd /usr/share/dialer/backend/ nano .env |
Copy the credentials from the Sonata Dialer database.
DB_HOST=127.0.0.1 DB_USERNAME=dialer DB_DATABASE=sonata_dialer DB_PASSWORD=8XAYbQTtz5RKsk5DI7hg |
And from the Asterisk database.
DB_ASTERISK_HOST=127.0.0.1 DB_ASTERISK_DATABASE=asterisk DB_ASTERISK_USERNAME=dialer DB_ASTERISK_PASSWORD=8XAYbQTtz5RKsk5DI7hg |
With this information, enter MariaDB and create Server 2 access to these databases.
mysql -uroot |
grant all privileges on sonata_dialer.* to “dialer”@”207.246.70.193” identified by “8XAYbQTtz5RKsk5DI7hg”; |
grant all privileges on asterisk.* to “dialer”@”207.246.70.193” identified by “8XAYbQTtz5RKsk5DI7hg”; |
FLUSH PRIVILEGES; exit |
Now we go back to Server 2 and configure the MariaDB connection credentials that we got from the configuration of Server 1. We are also going to change the DB_HOST to the IP of Server 1.
Go to /usr/share/dialer/backend and edit the .env file.
cd /usr/share/queues-stats/backend/ nano .env |
In the Stats database we should have something like this. Only DB_HOST and DB_PASSWORD is changed.
DB_HOST= 45.32.164.219 DB_USERNAME=dialer DB_DATABASE=sonata_dialer DB_PASSWORD=8XAYbQTtz5RKsk5DI7hg |
And from the Asterisk database.
DB_ASTERISK_HOST=45.32.164.219 DB_ASTERISK_DATABASE=asterisk DB_ASTERISK_USERNAME=dialer DB_ASTERISK_PASSWORD=8XAYbQTtz5RKsk5DI7hg |
Now we reload our Sonata Dialer, and everything should work fine. We have already installed Sonata Dialer on an External Server.
If for some reason it doesn’t connect, it could be that the MariaDB credentials are not correct. In some cases it is necessary to restart MariaDB on Server 1.
To test if the credentials are correct, we execute the following command on Server 2.
mysql -usonata_dialer -h 45.32.164.219 -p8XAYbQTtz5RKsk5DI7hg |
Conclusions
In these configurations that we explain here, all the information will always be on Server 1 (VitalPBX Server), making the backup and maintenance process easier.
If you want to update Sonata Suite, you must do so on both Servers.
As we could see in this Blog, it is very easy to install Sonata Suite on a separate server.
Take into account that the licenses only need to be registered on Server 1 (Main).
To install VitXi on a separate server please go to the following blog:
https://vitalpbx.com/blog/how-to-install-vitxi-on-an-external-server/