Code Monkey home page Code Monkey logo

freepbx's Introduction

FreePBX on Docker

FreePBX container image for running a complete Asterisk server.

With this container you can create a telephony system in your office or house with integration among various office branches and integration to external VOIP providers with features such as call recording and IVR (interactive voice response) Menus.

If "Apply" is taking too long, disable "Module signature check" (if you know what you're doing).

Security considerations:

  • Turn off SIP Guest on Settings -> Sip settings

  • Enable fail2ban with ENV FAIL2BAN_ENABLE=true (you have to run this container in privileged mode for this to work)

Thanks to https://github.com/tiredofit/docker-freepbx for various insights on the new Asterisk 15 installation.

This image is used in production deployments.

Image includes

  • Asterisk 16
  • FreePBX 15
  • Modules: IVR, Time Conditions, Backup, Recording
  • Automatic backup script

Usage

  • Create docker-compose.yml
version: '3.3'
services:
  freepbx:
    image: flaviostutz/freepbx
    ports:
      - 8080:80
      - 5060:5060/udp
      - 5160:5160/udp
      - 3306:3306
      - 18000-18100:18000-18100/udp
    restart: always
    environment:
      - ADMIN_PASSWORD=admin123
    volumes:
      - backup:/backup
      - recordings:/var/spool/asterisk/monitor

volumes:
  backup:
  recordings:

Sample host preparation

  • Install Ubuntu 18.04

  • Install Docker + Docker Compose

  • Configure network

    • edit /etc/netplan/50-cloud-init.yaml
network:
    ethernets:
        eno1:
            addresses:
               - 10.1.2.5/22
               - 10.223.49.234/29
            nameservers:
               addresses: [10.1.1.254,8.8.8.8]
            gateway4: 10.1.1.254
            routes:
               - to: 10.128.0.0/9
                 via: 10.223.49.233
    version: 2
  • run netplan apply

  • In this example suppose you have a VOIP provider in another network (10.223.x.x) connected to the Asterisk host. You can skip routes and the secondary address if not needed

  • Run this container

ENVs

  • ADMIN_PASSWORD - GUI password for user 'admin'. required

  • RTP_START - port range from for RTP. defaults to 18000

  • RTP_FINISH - port range to for RTP. defaults to 18100

  • SIP_NAT_IP - SIP NAT Public IP for calls. defaults to ip got from "curl ifconfig.me"

  • USE_CHAN_SIP - if true, disables pjsip and enables legacy chan_sip engine. defaults to false, meaning it will use pjsip engine by default

  • ENABLE_AUTO_RESTORE - if true, when a new container instance is run, it will try to restore an existing backup from /backup/[FreePBX ver]/new.tar.gz. This backup is created each one hour automatically. This is useful when creating a new container instance (all MYSQL and other data is lost), so that your configurations are kept. defaults to true

  • ENABLE_DELETE_OLD_RECORDINGS - Delete all recordings older than 60 days if enabled. defaults to true

  • FAIL2BAN_ENABLE - enable fail2ban on asterisk logs. If set, this container needs to run in "privileged" mode because it needs to change iptables configurations. defaults to 'false'

  • FAIL2BAN_FINDTIME - Time window in which failed retries will be evaluated. Defaults to '600' seconds

  • FAIL2BAN_MAXRETRY - Number of failed attempts inside "findtime" window. Defaults to '15' retries

  • FAIL2BAN_BANTIME - Time a specific IP will be banned after too many failed retries. Defaults to '259200' seconds.

  • FAIL2BAN_IGNOREIPS - Comma/space separated list of IPs to be ignored on fail2ban (will never ban)

  • DISABLE_SIGNATURE_CHECK - Disables module signature checks so that configuration reloads are way faster. Disable if you know what module signing protection means. defaults to false

  • CERTIFICATE_DOMAIN - certificate domain name when generating site certs with let's encrypt. this is used to locate certificated by name in /etc/asterisk/keys/ and configure Apache to use it automatically. defaults to ''

Fail2Ban

  • Enter freepbx container with docker exec -it [containerid] bash
  • For unbanning
    • Run fail2ban-client set sshd unbanip 192.168.1.69 OR
    • Run fail2ban-client unban --all
  • For listing all banned ips:
    • Run fail2ban-client status asterisk-iptables

Volumes

  • /backup - keeps new.tar.gz and old.tar.gz automatic backups. Default backup job stores backup there too. Backups are store inside a directory with freepbx version. Backup restore between different versions is not supported by Freepbx.

  • /var/spool/asterisk/monitor - call recording storage location

  • /etc/asterisk/keys - Let's Encrypt and self signed certificates pub/private keys generated in pbxadmin

freepbx's People

Contributors

alexmaurer-madis avatar flaviostutz avatar fsalomon avatar jmar71n avatar mika-nt28 avatar pavelpy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

freepbx's Issues

Backup cannot be restored

restoring from userman [FreePBX\modules\Userman\Restore]
Cleaning table: userman_users
"An exception occurred while executing 'INSERT INTO userman_users (id, auth, authid, username, description, password, default_extension, primary_group, permissions, fname, lname, displayname, title, company, department, language, timezone, dateformat, timeformat, datetimeformat, email, cell, work, home, fax) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params ["1", "1", "", "300", "Autogenerated user on new device creation", "$2a$08$1xBmhfQBPSNs5hhHGjGqMOooCe8JzjFWVMwygy81pv8qgJBzvrmY.", "300", "", "", "", "", "300", "", "", "", "", "", "", "", "", "", "", "", "", ""]:
"
"SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '' for column asterisk.userman_users.primary_group at row 1"

Container no longer starts

When building from scratch Container no longer starts
---> Running in c7d2053c6b16 Starting MariaDB database server: mysqld . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . failed! The command '/bin/sh -c /etc/init.d/mysql start && cd /usr/src/freepbx && echo "Starting Asterisk..." && cp /etc/odbc.ini /usr/src/freepbx/installlib/files/odbc.ini && ./start_asterisk start && sleep 3 && echo "Installing FreePBX..." && ./install -n && echo "Updating FreePBX modules..." && fwconsole chown && fwconsole ma upgradeall && fwconsole ma downloadinstall backup bulkhandler ringgroups timeconditions ivr restapi cel configedit asteriskinfo certman ucp webrtc && /etc/init.d/mysql stop && gpg --refresh-keys --keyserver hkp://keyserver.ubuntu.com:80 && gpg --import /var/www/html/admin/libraries/BMO/9F9169F4B33B4659.key && gpg --import /var/www/html/admin/libraries/BMO/3DDB2122FE6D84F7.key && gpg --import /var/www/html/admin/libraries/BMO/86CE877469D2EAD9.key && gpg --import /var/www/html/admin/libraries/BMO/1588A7366BD35B34.key && chown asterisk:asterisk -R /var/www/html && sed -i 's/www-data/asterisk/g' /etc/apache2/envvars && rm -rf /usr/src/freepbx*' returned a non-zero code: 1 ERROR: Service 'freepbx' failed to build

404 error in wget asterisk-15.7.1.tar.gz

Hi there,

the URL http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-15.7.1.tar.gz raised an 404 error, correct link is http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-15.7.2.tar.gz

Should change code in lines 28, 29 and 30 of Dockerfile's code, like this:

	&& wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-15.7.2.tar.gz \
	&& tar xfz asterisk-15.7.2.tar.gz \
	&& rm -f asterisk-15.7.2.tar.gz \

I will do a pull request.

Dashboard issues and permanent reloading on applying config

flaviostutz/freepbx (no tag) pulled 2020-07-24
Freepbx 15.0.16.68

Issues:
1. Dashboard reports ".htaccess files are disable on this webserver. Please enable them"
2. Mail Queue reports (on dashboard) "unknown output from exim..."
3. There is no ability to configure email
4. FreePBX statistics panel on dashboard does not show hourly asterisk stats
5. Applying a change to config leaves "reloading" dialog with bar at 100% permanently on screen.

g729 codec issue

Dude, first of all, congratulations for your awesome work!!!

Second, i'm having some troubles for install g729 codec in your docker image, can you give me some guidances?

Third... PARABÉNS!!!! e MUITO SUCESSO!!!!

Can't initialize iptables table 'filter'

I was using the following docker-compose.yaml:

version: '3.3'
services:
  freepbx:
    image: flaviostutz/freepbx
    ports:
      - 8092:80
      - 5060:5060/udp
      - 5160:5160/udp
      - 3306:3306
      - 18000-18100:18000-18100/udp
    environment:
      - ADMIN_PASSWORD=admin123
    volumes:
      - backup:/backup
      - recordings:/var/spool/asterisk/monitor

volumes:
  backup:
  recordings:

I have the following logs:

~/Downloads/freepbx$ sudo docker-compose logs -t -f --tail 10
Attaching to freepbx_freepbx_1
freepbx_1  | 2022-01-03T14:15:45.791808263Z iptables v1.8.2 (legacy): can't initialize iptables table `filter': Permission denied (you must be root)
freepbx_1  | 2022-01-03T14:15:45.791959813Z Perhaps iptables or your kernel needs to be upgraded.
freepbx_1  | 2022-01-03T14:15:45.795578022Z For enabling fail2ban you have to run this container with 'privileged: true'
freepbx_freepbx_1 exited with code 1

I have not configured the network in any way or applied netplan.

CDR records not shown

Hi, thank you for creating this useful docker image, I am using your image since FreePBX14.

However I setup the latest FreePBX15 with all my phones working, but I don't get any CDR records shown. The mariaDB process is running without problems.

Inside the container is the file /etc/asterisk/cdr_adaptive_odbc.conf which I suppose is responsible for connecting FreePBX with mariaDB. The contents of the file are:
[asteriskcdrdb]
connection=asteriskcdrdb
loguniqueid=yes
table=cdr
alias start => calldate

In case you need any more info, please tell me. Thank you for help, it's greatly appreciated.

No CDRs

I created a new container, added a trunk, outbound/inbound route. Placed a call and CDR is empty. So I backed up the CDR from my previous virtual machine installation of FPBX15 and restored in the container. I can see the old entries now, but still no new entries show up.

I saw in the following in the asterisk log:

[2020-09-15 19:46:48] NOTICE[328] cdr.c: CDR simple logging enabled.
2297[2020-09-15 19:46:48] WARNING[328] cdr_manager.c: Failed to load configuration file. Module not activated.
2298[2020-09-15 19:46:48] WARNING[328] cdr_sqlite3_custom.c: Failed to load configuration file. Module not activated.
2299[2020-09-15 19:46:48] ERROR[328] loader.c: Error loading module ‘cdr_adaptive_odbc.so’: libodbc.so.2: cannot open shared object file: No such file or directory
2300[2020-09-15 19:46:48] ERROR[328] loader.c: Error loading module ‘cdr_odbc.so’: libodbc.so.2: cannot open shared object file: No such file or directory
2301[2020-09-15 19:46:48] ERROR[328] loader.c: cdr_manager declined to load.
2302[2020-09-15 19:46:48] ERROR[328] loader.c: cdr_csv declined to load.
2303[2020-09-15 19:46:48] ERROR[328] loader.c: cdr_sqlite3_custom declined to load.

Any idea why this is occurring?

Works once then stops container running

Ran container startup works fine but after a container restart in Portainer it no longer runs, portainer log has the error

target prot opt source destination
Enabling fail2ban for asterisk logs at /var/log/asterisk/full
mkdir: cannot create directory '/var/run/fail2ban': File exists
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Enabling fail2ban for asterisk logs at /var/log/asterisk/full
mkdir: cannot create directory '/var/run/fail2ban': File exists

I tried on two systems, one Ubuntu and the other Openmediavault both with the same error

Can't transmit voice between two sophtfones extensions

Hi,

I set up and launched the image under windows 10, I configured two extensions and installed two softphtones associated to these extensions. I can call from first softphone to second, but when I picked up, I can't listen, transmit voices between these two softphones. I've called to *30 echo number, but I can'hear anything. So can you please pointing me to some directions of solutions.
I've also tried disabled the windows firewall, but anything not changed.

Thanks for advance

Refactor Database deployment

Is there a specific reason why the db is running alongside asterisk inside the container? I think it is common for Docker to separate concerns for a number of reasons?

Calls drop after 6 seconds

Hello!

Pretty sure it's a nat issue, but I can't figure out where...

I am spinning this up on Docker CE Version 20.10.7 on Ubuntu Server 20.04.2 LTS with docker-compose version 1.29.2.

I copied the example docker-compose in the readme and made minor tweaks to fit my system:

version: '3.3'
services:
freepbx:
image: flaviostutz/freepbx:latest
container_name: freepbx
ports:
- 8080:80
- 5060:5060/udp
- 5160:5160/udp
- 3307:3306
- 18000-18100:18000-18100/udp
restart: always
environment:
- ADMIN_PASSWORD=admin1234
- USE_CHAN_SIP=true
- FAIL2BAN_ENABLE=false
- ENABLE_AUTO_RESTORE=true
volumes:
- /root/docker-configs/freepbx/backup:/backup
- /root/docker-configs/freepbx/recordings:/var/spool/asterisk/monitor

I had to bump the 3306:3306 binding to 3307:3306 because I have a MySQL container already ready on 3306 on this box for the rest of my network and it conflicted.

I created folder volumes on the drive because of how I have my backup plans set and other containers needed an actual folder that i have running so I am not using internal Docker volumes.

So here is what I have happening. Spins up fine. I am able to setup the server, create extensions and have 2 softphones register to those extensions.

When I try to make a call, the call just drops after 6 seconds with no audio.

In the past when I had this issue, it was usually a NAT issue somewhere so...
I checked the NAT mode settings on the extensions, and they are set to Yes - (force_rpot,comedia) like i have needed to in the past.
Looked at Settings -> Asterisk SIP Settings - > General Settings:
Allow SIP Guests No
Detect Network Settings Button to get external IP
local networks: Added 10.0.0.0/24 (which is my home network) and 172.0.0.0/24 (the internal network docker created for this stack)

Looked at Settings -> Asterisk SIP Settings - > SIP Legacy Settings:
NAT yes
IP Configuration Static IP
Override External IP is grayed and show my external IP (which it should)

and nothing.... The calls still drop....

Tried to run the container in network_mode: host

the container lasts for about 30 seconds and then tries to restart. More then likely this is because it's trying to spin up it's internal MySQL server on 3306 but this is just a guess...

So not sure where to proceed from here. I would love to get this working since I finally have the hardware to do it and get my existing Home Freepbx off an Rpi I have had it running on to free it up for another project.

Thanks for any assistance....

Jeff

Help to install this repo

I can't install this repo in my server
I install with this instruction but I don't connect to http://192.168.0.xxx:8080/
sudo docker pull flaviostutz/freepbx
sudo docker run --name freepbx -d flaviostutz/freepbx

I see that it is launched on port 80 which is already used
sudo docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0d77e8a342c2 flaviostutz/freepbx "/bin/sh -c /run/sta…" 6 minutes ago Up 5 minutes 80/tcp, 3306/tcp, 4569/tcp, 5060-5061/tcp, 5160-5161/tcp, 10000-20000/udp freepbx

And if i change port
sudo docker run --name freepbx -p 8080:80 -d flaviostutz/freepbx
f0964157f08033a7f5deda9c6d653f042ae87aa08f2e7eded690a9c9824a814b
sudo docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f0964157f080 flaviostutz/freepbx "/bin/sh -c /run/sta…" 34 seconds ago Up 23 seconds 3306/tcp, 4569/tcp, 5060-5061/tcp, 5160-5161/tcp, 10000-20000/udp, 0.0.0.0:8080->80/tcp freepbx

After restart All the settings cleared

Hi.
Installed and set up the settings. It was working. Then tried to restart the container. All of my settings was cleared.

Am i doing something wrong? Or is there a problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.