Tuesday, March 2, 2021

Install Asterisk 18 / FreePBX 15 on Ubuntu [Raspberry PI 4]

An updated version of this post is available here.

I use this tutorial to setup RemoSIM.com product for customers.




RasPBX – Asterisk for Raspberry Pi is a cost-effective solution to run Asterisk VoIP server on RaspberryPi. The installation is very simple and the web interface makes it super easy to run a low-cost VoIP solution.

I installed RasPBX and used its chan_dongle module to route calls / SMS from sim cards to VoIP/Telegram. It was a long story described in this post to eventually reach a stable setup. 

The setup I had with RasPBX was constantly resetting usb dongles say every 10-30mins. I decided to switch to Ubuntu for Raspberry Pi and install the latest version of Asterisk 18.x instead of Asterisk 16.x provided in RasPBX/Ubuntu and interestingly enough, it resolved the problem I had with disconnecting USB dongles.

So in this post, I'm going to describe how to install Asterisk 18.x with chan_dongle module, Fail2Ban and FreePBX on Ubuntu for RaspberryPI and use CLI interface to configure it.

 Steps:

Download Ubuntu 20.04 LTS for Raspberry PI and burn the image to your microsd card. 

SSH to your raspberry: ssh ubuntu@raspberry.IP.Address , the default password is ubuntu

# update packages there 
sudo apt-get update && sudo apt-get dist-upgrade -y

#freepbx installation must be run as root, so login to SSH as root :

sudo passwd
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
service sshd restart

# Install required packages, note that freepbx 15 does not support php v7.4 so we have to install php v7.3
add-apt-repository universe

add-apt-repository ppa:ondrej/php

apt-get install -y build-essential linux-headers-`uname -r` openssh-server apache2 mariadb-server mariadb-client bison flex php7.3 php7.3-curl php7.3-cli php7.3-pdo php7.3-mysql php-pear php7.3-gd php7.3-mbstring php7.3-intl php7.3-xml  curl sox libncurses5-dev libssl-dev mpg123 libxml2-dev libnewt-dev sqlite3 libsqlite3-dev pkg-config automake libtool autoconf git unixodbc-dev uuid uuid-dev libasound2-dev libogg-dev libvorbis-dev libicu-dev libcurl4-openssl-dev libical-dev libneon27-dev libsrtp2-dev libspandsp-dev sudo subversion libtool-bin python-dev unixodbc dirmngr sendmail-bin sendmail htop cmake libmariadb-dev-compat

# or on Raspbian OS:
apt-get install -y build-essential raspberrypi-kernel-headers openssh-server apache2 mariadb-server mariadb-client bison flex php7.3 php7.3-curl php7.3-cli php7.3-pdo php7.3-mysql php-pear php7.3-gd php7.3-mbstring php7.3-intl php7.3-xml  curl sox libncurses5-dev libssl-dev mpg123 libxml2-dev libnewt-dev sqlite3 libsqlite3-dev pkg-config automake libtool autoconf git unixodbc-dev uuid uuid-dev libasound2-dev libogg-dev libvorbis-dev libicu-dev libcurl4-openssl-dev libical-dev libneon27-dev libsrtp2-dev libspandsp-dev sudo subversion libtool-bin python-dev unixodbc dirmngr sendmail-bin sendmail htop cmake libmariadb-dev-compat




# install nodejs
curl -sL https://deb.nodesource.com/setup_12.x | bash -
apt-get install -y nodejs
curl https://www.npmjs.com/install.sh | sh

# required pear package
pear install Console_Getopt

#add the following line to [mysqld] section of /etc/mysql/mariadb.conf.d/50-server.cnf
sql_mode=NO_ENGINE_SUBSTITUTION

# restart mariadb
service mariadb restart

# download and install asterisk 18
cd /usr/src
rm -fr asterisk-18-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-18-current.tar.gz
tar xvfz asterisk-18-current.tar.gz
cd asterisk-18.*
contrib/scripts/get_mp3_source.sh
contrib/scripts/install_prereq install
./configure --with-pjproject-bundled --with-jansson-bundled
make menuselect.makeopts
menuselect/menuselect --enable app_macro --enable format_mp3 menuselect.makeopts
make
make install
make config
ldconfig
update-rc.d -f asterisk remove

# correct asterisk permissions
useradd -m asterisk
chown asterisk. /var/run/asterisk
chown -R asterisk. /etc/asterisk
chown -R asterisk. /var/{lib,log,spool}/asterisk
chown -R asterisk. /usr/lib/asterisk
rm -rf /var/www/html
mkdir /var/www/html # freepbx reinstall needed

# update apache config
sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php/7.3/apache2/php.ini
cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf_orig
sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/apache2/apache2.conf
sed -i 's/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf
a2enmod rewrite
service apache2 restart

cd /usr/src
wget https://dlm.mariadb.com/1489919/Connectors/odbc/connector-odbc-3.1.11/mariadb-connector-odbc-3.1.11-ga-src.tar.gz
tar -zxvf mariadb-connector-odbc-3*
cd mariadb-connector-odbc-3*
mkdir build
cd build
DM_DIR=/usr/lib/aarch64-linux-gnu cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONC_WITH_UNIT_TESTS=Off -DCMAKE_C_FLAGS_RELWITHDEBINFO="-I/usr/include/mariadb -L/usr/lib"
## OR on raspbian:
DM_DIR=/usr/lib/arm-linux-gnueabihf cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONC_WITH_UNIT_TESTS=Off -DCMAKE_C_FLAGS_RELWITHDEBINFO="-I/usr/include/mariadb -L/usr/lib"
##
make
make install

# Configure ODBC

cat <<EOF > /etc/odbcinst.ini
[MySQL]
Description = ODBC for MySQL (MariaDB)
Driver = /usr/local/lib/mariadb/libmaodbc.so
FileUsage = 1
EOF


cat <<EOF > /etc/odbc.ini
[MySQL-asteriskcdrdb]
Description = MySQL connection to 'asteriskcdrdb' database
Driver = MySQL
Server = localhost
Database = asteriskcdrdb
Port = 3306
Socket = /var/run/mysqld/mysqld.sock
Option = 3
EOF

# Download and install freepbx which requires php7.3
cd /usr/src
wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-15.0-latest.tgz
tar vxfz freepbx-15.0-latest.tgz
touch /etc/asterisk/{modules,cdr}.conf
cd freepbx
./start_asterisk start
./install -n
fwconsole ma disablerepo commercial
fwconsole ma install callrecording core dashboard customappsreg infoservices logfiles pm2 sipsettings voicemail 
fwconsole reload

# Installing chan_dongle
apt-get install usb-modeswitch -y
cd /usr/src
git clone https://github.com/wdoekes/asterisk-chan-dongle
cd asterisk-chan-dongle
./bootstrap
./configure --with-astversion=18.5 --with-asterisk=/usr/src/asterisk-18.5.0/include

# I have noticed that using SIM memory card as the default storage for SMS causes text messages to not receive every once in a while. So set chan_dongle to use dongle memory for SMS by default:
##sed -i at_command.c -e 's#AT+CPMS=\\"SM\\",\\"SM\\",\\"SM\\"#AT+CPMS=\\"ME\\",\\"ME\\",\\"ME\\"#g'

# fix the "dongle reset dongleX" command for E171 firmware  , this dongle needs to be reset using AT^RESET instead of AT^CFUN=1,1 so we send both commands to the modem

##sed -i at_command.c -e 's#AT+CFUN=1,1\\r#AT+CFUN=1,1\\rAT^RESET\\r#g'

make
make install

# chown ttyUSB* devs to asterisk
echo 'KERNEL=="ttyUSB*", GROUP="dialout", OWNER="asterisk"' > /etc/udev/rules.d/50-udev-default.rules

# Freepbx startup script: /etc/systemd/system/freepbx.service
[Unit]
Description=FreePBX VoIP Server
After=mariadb.service
 
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/fwconsole start -q
ExecStop=/usr/sbin/fwconsole stop -q
 
[Install]
WantedBy=multi-user.target

# Enable swap area on Raspberry 
dd if=/dev/zero of=/swapfile bs=1G count=1
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile

# add the following line to /etc/fstab
/swapfile swap swap defaults 0 0

# delete journald folder so that it stores logs to RAM to avoid high disk io
rm -fr /var/log/journal

# compile atinout command 
cd /usr/src
wget http://sourceforge.net/projects/atinout/files/v0.9.1/atinout-0.9.1.tar.gz
tar -zxvf atinout*.gz
cd atinout-0.9.1
sed -i Makefile -e "s,-Werror,,g"
make
make install
mkdir /scripts

# add this script to send commands to all dongles {0..4} , 4 should be replaced by the number of dongles you have minus one
# vi /scripts/at
#!/bin/bash

dataports=`for i in {0..4}; do asterisk -rx "dongle show device state dongle$i" | grep "Device\|USB" | grep Data | awk '{print $3}'; done`

for data in $dataports; do
echo "$1" | timeout 1 atinout - $data - 2>&1
done

# add this script to remove all sms messages from sim cards / dongles : 
# vi /scripts/deletesms.sh
#!/bin/bash
# Storage types: https://www.developershome.com/sms/cpmsCommand.asp
# Reading commands: https://www.developershome.com/sms/cmgrCommand2.asp
# Delivery reports: https://stackoverflow.com/questions/18251903/how-to-handle-delivery-report-in-gsm-modem
/scripts/at AT+CPMS=\"SR\",\"SR\",\"SR\"
/scripts/at AT+CMGD=1,4
/scripts/at AT+CPMS=\"MT\",\"MT\",\"MT\"
/scripts/at AT+CMGD=1,4
/scripts/at AT+CPMS=\"ME\",\"ME\",\"ME\"
/scripts/at AT+CMGD=1,4
/scripts/at AT+CPMS=\"SM\",\"SM\",\"SM\"
/scripts/at AT+CMGD=1,4

# make them executable
chmod +x /scripts/at
chmod +x /scripts/deletesms.sh

# add deletesms.sh to cronjobs to avoid this bug 
# crontab -e
0 */6 * * * /scripts/deletesms.sh

# Adding a useful alias command: s
# typing s in shell would show status of all dongles with a refresh rate of 1 second:
# vi ~/.bashrc
alias s="watch -n1 'asterisk -rx \"dongle show devices\"'

# s alias command: 
# keep an eye on the RSSI column there which shows signal strength. RSSI values above 15 are good.
# a low RSSI below 15 might result in dongle reset and constant "GSM not registered" error


# add the following cron jobs to keep raspberrypi updated
apt-get install rpi-eeprom -y
crontab -e
0 14 * * * apt-get update && apt-get dist-upgrade -y
0 17 * * * /usr/sbin/fwconsole ma refreshsignatures && /usr/sbin/fwconsole ma upgradeall
30 17 * * * /usr/sbin/fwconsole setting SIGNATURECHECK 0
30 17 * * * /usr/sbin/fwconsole setting MODULEADMINEDGE 1
0 18 * * * /usr/bin/rpi-eeprom-update -a


# The following script can be used to monitor your local VPN network (10.0.1.1 here)  and restart the vpn service (wireguard in this example) if the connection was not available. 
# vi /scripts/nointernet.sh
#!/bin/bash
if ping -c 1 10.0.1.1 &> /dev/null
then
  echo 1
else
  echo 0
  /bin/systemctl restart wg-quick@wg0
  /bin/systemctl restart wg-quick@wg1
  sleep 5
  /scripts/tg.py --sender 'System' --dongle 'system' --destination 'system' --message "There was no internet connection, the VPN service was restarted"

fi

# The following scripts can be used to monitor number of dongles you have ( here 5 ) and restart them if they were disconnected
# vi /scripts/down.sh

#!/bin/bash
numdongles=5
downs=$(/usr/sbin/asterisk -rx "dongle show devices" | grep "Not connec\|GSM not\|Unknown" | awk '{print $1}')
now=$(date +'%m-%d-%Y')

# reset down dogles
for down in $downs; do
        /scripts/tg.py --sender 'system' --dongle 'system' --destination 'system' --message "dongle $down was down and it was reset";
        /usr/sbin/asterisk -rx "dongle reset $down";
#        /usr/sbin/asterisk -rx "dongle restart now $down";
done

# need to reset raspberry if all dongles are in Not connected state :
downs=$(/usr/sbin/asterisk -rx "dongle show devices" | grep "Not connec" | awk '{print $1}' | wc -l)
if [ $downs -eq $numdongles ]; then
        /scripts/tg.py --sender 'system' --dongle 'system' --destination 'system' --message "all donlges were down and the pi was restarted";
        /bin/dmesg > /scripts/log/dmesg-$now.txt
        /scripts/restart.sh
fi

# need to reset raspberry if one of dongles is disconnected
notconnected=$(/usr/bin/lsusb | grep Huawei | wc -l)
if [ $notconnected -ne $numdongles ]; then
        /scripts/tg.py --sender 'system' --dongle 'system' --destination 'system' --message "one of dongles was not listed in lsusb and the dongle was restarted";
        /bin/dmesg > /scripts/log/dmesg-$now.txt;
        /scripts/restart.sh
fi

# The following script can be used to restart raspberry  / hubs 
# vi /scripts/restart.sh
#!/bin/bash
# restart raspberry 
#echo b > /proc/sysrq-trigger
# or restart the usb hub
hubs=`uhubctl --vendor 05e3 | grep status | awk '{print $5}'`;
for hub in $hubs;
 do uhubctl --loc $hub --action 2;
done
sleep 5
/usr/sbin/asterisk -rx "dongle discovery"

# Add the above monitoring scripts, and also two cron jobs to remove raspberry logs when they become large
# crontab -e
*/5 * * * * /scripts/nointernet.sh
*/10 * * * * /scripts/down.sh
0 * * * * /usr/bin/find /var/log/ -type f -size +500M  -delete
0 * * * * /usr/bin/find /home/ -type f -size +500M  -delete


# Restart raspberrypi
reboot


# After reboot, set your GSM dongles to Modem-only:
/scripts/at AT^U2DIAG=0
/scripts/at AT^SETPORT=\"A1,A2\;1,3,2,A2\" #for E171 Firmware 21.156.00.00.143 (requires { 0x12d1, 0x1506, { 2, 1, /* 0 */ } }, in pdiscovery.c of asterisk-chan-dongle) , disables cdrom and network adapter

#/scripts/at AT^SETPORT=\"A1,A2\;1,16,3,2,A2\" #for E171 Firmware 21.156.00.00.143 (requires { 0x12d1, 0x1506, { 3, 2, /* 0 */ } }, in pdiscovery.c of asterisk-chan-dongle) , disables cdrom

Tuesday, December 22, 2020

[Solved] Proxmox 6.3 error on RH2288 V3 Huawei Servers: No working lease in persistent database


Proxmox 6.x does not enter installation on RH2288 V3 servers for some reason and it drops to shell with this error:

No working lease in persistent database

Digger412 has suggested a workaround here .


Enter E key on proxmox splash page then add the following arguments :

modprobe.blacklist=nouveau amd_iommu=on video=efifb:off


then press Ctrl+x to boot. It worked pretty well for me.

p.s.

You can get internet access in proxmox debug shell by assigning your IP / Gateway to the interface on the fly:

ip addr show

ip addr add YOUR.IP.ADDRESS/PREFIX dev enp2s0f0

ip route add default via YOUR.GATEWAY.ADDRESS dev enp2s0f0


How Install kernel headers on Sangoma OS

I installed FreePBX Sangoma OS on VirtualBox and tried to install Guest Additions there:

VirtualBox -> Devices -> Insert Guest Additions CD image...

the on the VM:

yum install dkms gcc kernel-devel kernel-headers -y

mkdir /media/cdrom

mount /dev/cdrom /media/cdrom

cd /media/cdrom

./VBoxLinuxAdditions.run

it returns the following error while kernel headers are already installed: 

VirtualBox Guest Additions: Kernel headers not found for target kernel 3.10.0-1127.19.1.el7.x86_64. 

This is while we have already installed kernel-devel and kernel-headers packages. This error is because the build folder in /lib/modules/$(uname -r) is missing in the default FreePBX Sangoma installation for some reason.

To fix this problem, run the following command:

ln -s /usr/src/kernels/$(uname -r) /lib/modules/$(uname -r)/build

then run 

./VBoxLinuxAdditions.run

again to build Linux Guest Additions.


Tuesday, December 15, 2020

Install the last version of tesseract on debian 11

 Get the latest version number from here and update v variable in the following gist:

v=4.1.1

apt-get install g++ autoconf automake libtool pkg-config libpng-dev libjpeg62-turbo-dev libtiff5-dev zlib1g-dev libleptonica-dev -y

cd /usr/src

wget https://github.com/tesseract-ocr/tesseract/archive/$v.tar.gz

tar -zxvf $v.tar.gz

cd tesseract-$v

./autogen.sh

./configure --prefix=/usr/local

make

make install

wget https://github.com/tesseract-ocr/tessdata/raw/master/eng.traineddata -O /usr/local/share/tessdata/eng.traineddata


Sunday, December 13, 2020

RaspberryPI 4B+ and GSM Dongles

I managed to run 4 GSM donlges on RaspberryPi 4B+ in a stable production eventually although it was not an easy process. I had four UMG1691 GSM dongles that I wanted to use with raspberry-asterisk.

-------

Update 4: 19/June/2021:

I noticed intermittent disconnects in the dongles, it was apparently due to weak 3g signal. I suppose the operator stopped one of the antennas it had in our region which caused the weak signal problem. (RSSI <15)

I had to switch the dongles to 2G (AT^SYSCFG=13,1,3FFFFFFF,0,2) to get a better signal however dongles keep resetting frequently and it was very unstable. I had DUB H7 D-Link hub which is recommended here however I was not able to get dongles working in 2G mode with this hub.

I ordered a TP-Link UH700 USB 3.0 hub and the dongles are now working in 2G mode and they are very stable (RSSI > 23). This USB hub uses VL812 chip which I think is the reason why its compatible with 2G dongles (needs to be verified). There are some other hubs with this chipset which can be tested to confirm this.



I think a better hub choice would be TP-Link UH720 which has two 2.4A ports which can be used the also power the raspberry pi. DUB-1370 may also be compatible, it needs testing. I had tested this "4 Port USB3.0 Transparent HUB" Orico hub  and it was not compatible with 2G dongles. 

I also found that the Mode / Submode values are not important, my dongles work fine in 2G with mode/submode 3/3 or 0/0, and in 3G with mode/submode 5/4 or 0/0 . I had a dongle that was not functioning properly even when it was shown as Free in asterisk, it was a E171 dongle with firmware v21.x . 

Update 3: 26/April/2021:

The four sim cards in the dongles were from 3 different network operators. I noticed that the simcards  from one of the network operators do not work stably and they reset frequently. I was getting 

ID           Group State      RSSI Mode Submode

dongle2      0     GSM not re 20   5    4 

I was getting Mode 5 Submode 4 on the dongle having the sim card. This was resolved by transferring the phone number to another network operator. Now asterisk shows a Mode 0 Submode 0 like the rest of the dongles and it is all stable.

ID           Group State      RSSI Mode Submode

dongle2      0     Free       25   0    0 

Update 2: 2/March/2021:

Although my setup from Update 1 was stable, the gsm dongles used to reset / disconnect every 10-60mins randomly, I had the following errors in dmesg: 

[14176.370665] usb 1-1.3.4-port4: Cannot enable. Maybe the USB cable is bad?

[14176.370984] hub 1-1.3:1.0: hub_ext_port_status failed (err = -110)

[14177.410797] usb 1-1.3.4-port4: cannot disable (err = -110)

[14054.689390] usb 1-1.3.4-port1: cannot reset (err = -110)

and even sometimes lsusb didnt show dongles after the above errors and a restart was required. 

I decided to try Ubuntu 20.04LTS for Raspberry PI + Asterisk 18 and it worked decently without even a single dongle disconnect / restart in 24 hours. I have published the instructions to install freepbx/asterisk 18/ ubuntu 20.04 LTS on Raspberry PI in my post here.


UPDATE 1: 23/Dec/2020:

The UMG1691 modems were not stable at all for production due to RF problems in 2G. 

I eventually dropped all these modems and went for four new 3G modems: E1550, E153, E173 and E171

They work pretty well with D-Link DUB-H7 port when set to 3G only mode :

^SYSCFG:14,2,3FFFFFFF,0,2

It is finally Stable :



-------

First, RaspberryPI 4B+ allows a Maximum total USB peripheral current draw of 1.2A. This is not enough if you are going to use four GSM dongles in which each dongle uses 0.5A, you would need a total USB current draw of 2A.

One might think to use a powered USB hub. I tried this Orico USB3 hub and this D-Link USB2 Hub however they did not work. There are some reports that GSM dongles might have problems with USB hubs and using 3G mode might fix it. In my experience, the GSM dongles got reset frequently and the OS reported errors like:

usb 1-1-port2: cannot reset (err = -110)

Second, the 4 USB ports on RaspberryPi are designed so close to each other that it makes it impossible to connect 4 dongles directly to the raspberry. You would need a USB cable extension. Casual USB2.0 extension cables won't work and it leads to 

usb 1-1-port2: Cannot enable. Maybe the USB cable is bad?

errors in dmesg. You would need to use USB3.0 extension cables even for usb2 ports to connect your dongles.

Third, after connecting all GSM dongles to the raspberry, you may get

usb usb2-port1: over-current change #1

error in dmesg. I tried three things here :

- Add max_usb_current=1 to /boot/config.txt

- Use minicom or atinout to directly send AT commands to your GSM dongles and set SYSCFG on all your dongles to 2G only which uses less power than 3G

- Use a 5V 3A USB adapter on your raspberry and check that your raspberry is not undervoltaged :

/opt/vc/bin/vcgencmd get_throttled

and also check dmesg to ensure that the usb ports did not get overcurrent:

dmesg | grep -i curr

so my setup is now stable with the above precautions and everything seems to work fine, it took me 3 weeks for to figure out all the above

- Disable wifi and bluetooth modules if you don't need them, add dtoverlay=disable-wifi and dtoverlay=disable-bt to /boot/config.txt 

and finally reboot raspberry for the changes to apply.

- I had this problem that dongles stopped receiving SMS after some time. Whenever I inserted the sim card on a mobile phone, text messages were received fine. This problem is described here and the solution is to add a cronjob in your raspberry pi to delete SMS storage of the sim card / dongle periodically. 

Monday, November 23, 2020

[Howto] Install and configure Munin on Centos 8

Install munin first:

yum install epel-release -y

yum install munin munin-cgi munin-node munin-apache munin-common munin-plugins-ruby -y


Check the services that munin has installed in systemd:

systemctl list-unit-files | grep -i munin

Enable all available munin plugins:

munin-node-configure --shell --families=contrib,auto | sh -x

Start and enable munin-node which collects data on the system, we restrict this service to localhost:

sed -i /etc/munin/munin-node.conf -e "s,^host \*,#host \*,g"

sed -i /etc/munin/munin-node.conf -e "s,^#host 127.0.0.1,host 127.0.0.1,g"

systemctl enable munin-node --now

Enable munin in systemd timer:

sed -i /etc/munin/munin.conf -e "s,#graph_strategy cron,graph_strategy cron,g"

sed -i /etc/munin/munin.conf -e "s,#html_strategy cron,html_strategy cron,g"

sed -i /etc/munin/munin.conf -e "s,#htmldir,htmldir,g"

systemctl enable munin.timer --now


check if munin timer is running properly

systemctl list-timers --all


and finally add a virtualhost to apache or nginx to show the graphs. Check the examples here (Periodically generate graphs and HTML pages).

For apache: 

<VirtualHost _IP_:80>

    ServerName _IP_

    DocumentRoot /var/www/html

    Alias /munin/static/ /etc/munin/static/

    <Directory /etc/munin/static>

        Require all granted

    </Directory>

    # Disabling caching

    RewriteEngine On

    <FilesMatch "\.(html|htm|jpg|png)$">

      FileETag None

      <IfModule mod_headers.c>

        Header unset ETag

        Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"

        Header set Pragma "no-cache"

        Header set Expires "Wed, 12 Jan 1980 05:00:00 GMT"

      </IfModule>

    </FilesMatch>

    # Password protect the folder

    <Directory /var/www/html>

AuthType Basic

AuthName "restricted area"

AuthUserFile /var/www/.htpasswd

require valid-user

    </Directory>

    ScriptAlias /munin-cgi/munin-cgi-graph /var/www/html/munin/cgi/munin-cgi-graph

    # ScriptAlias /munin /var/www/html/munin/cgi/munin-cgi-html

    <Directory /var/www/html/munin/cgi>

        Require valid-user

        AuthName "restricted area"

            AuthUserFile /var/www/.htpasswd

        <IfModule mod_fcgid.c>

            SetHandler fcgid-script

        </IfModule>

        <IfModule !mod_fcgid.c>

            SetHandler cgi-script

        </IfModule>

    </Directory>

    CustomLog /var/log/httpd/munin-access.log combined

    ErrorLog  /var/log/httpd/munin-error.log

</VirtualHost>

Create your .htpasswd file :

htpasswd -c /var/www/.htpasswd monit

and reload apache.

for nginx add the following to your monit vhost: 

location = / {

    rewrite ^/$ munin/ redirect; break;

}

location /munin/static/ {

    alias /etc/munin/static/;

    expires modified +1w;

}


location /munin/ {

    auth_basic            "Restricted";

    auth_basic_user_file  /var/www/.htpasswd;

    alias /var/www/html/munin/;

    expires modified +310s;

}

location ^~ /munin-cgi/munin-cgi-graph/ {

    auth_basic            "Restricted";

    auth_basic_user_file  /var/www/.htpasswd;

    access_log off;

    fastcgi_split_path_info ^(/munin-cgi/munin-cgi-graph)(.*);

    fastcgi_param PATH_INFO $fastcgi_path_info;

    fastcgi_pass unix:/var/run/munin/munin-cgi-graph.sock;

    include fastcgi_params;

}

then run

service nginx reload

systemctl enable munin-cgi-graph.socket --now

Tuesday, September 22, 2020

[Howto] Install BigBlueButton on Centos 8 using docker

BigBlueButton only supports Ubuntu distros however it is possible to install it on almost any linux distro using docker. Here is the instruction I use to install it on Centos 8 : 

# Installing docker
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
dnf module enable container-tools
dnf install container-selinux
dnf module disable container-tools
yum install docker-ce docker-ce-cli containerd.io
curl -L "https://github.com/docker/compose/releases/download/1.27.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
mkdir -p ~/.docker
##### ONLY IF YOU NEED TO USE A PROXY FOR DOCKER CONTAINERS
echo '{
{
 "proxies":
 {
   "default":
   {
     "httpProxy": "http://X:Y",
     "httpsProxy": "http://X:Y",
     "noProxy": "216.93.246.18, YOURDOMAIN, YOURIP, localhost, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 127.0.0.1, 0.0.0.0, postgres, etherpad, html5, webrtc-sfu, core, host.docker.internal"
   }
 }
}
' \
> ~/.docker/config.json
###
systemctl daemon-reload
systemctl enable docker --now


# Install bbb-docker

cd /usr/src
git clone --recurse-submodules https://github.com/alangecker/bigbluebutton-docker.git bbb-docker
cd bbb-docker
./scripts/setup
./scripts/compose up -d

and finally proxy requests to your web server . Note that you need to forward requests to 127.0.0.1:8080 and not the IP address of greenlight vm.

How to Stream RTSP / Webcam / IP Camera Over the Web

I had a Hikvision IPC-B120 that provides a simple RTSP stream, which I could view in VLC. I also wanted to see my Logitech BRIO’s feed in a ...