# Linphone-SDK Ubuntu 22.04 Dockerイメージの作成とアプリのビルド（IPv6対応）

**URL:** <https://forum.ficusonline.com/t/topic/479>\
**Category:** Server\
**Created:** [2023 年 1 月 31 日午前 7:21 UTC](https://forum.ficusonline.com/t/topic/479 "2023-01-31T07:21:35Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2023 年 1 月 31 日午前 7:21 UTC](https://forum.ficusonline.com/t/topic/479/1 "2023-01-31T07:21:36Z")

</div>

## Linphone-SDK Dockerイメージの作成（Ubuntu 22.04）

[https://github.com/BelledonneCommunications/linphone-sdk](https://github.com/BelledonneCommunications/linphone-sdk)

[https://gitlab.linphone.org/BC/public/linphone-sdk/-/tree/master](https://gitlab.linphone.org/BC/public/linphone-sdk/-/tree/master)

Linphone-SDKのDockerコンテナ内でLinphoneアプリやflexisipサーバをビルドするため、Linphone-SDKのDockerイメージを作成します。必要なのは下記でダウンロードした **`docker-files`** ディレクトリです。

```auto
$ git clone https://gitlab.linphone.org/BC/public/linphone-sdk.git

```

**`docker-files`** ディレクトリ内の **`bc-dev-ubuntu-rolling`** を参考にして `Ubuntu 22.04` に対応した新規ファイルを作成します。

[How to Switch to Ubuntu Rolling Rhino: A Rolling Release Version of Ubuntu](https://www.makeuseof.com/install-ubuntu-rolling-rhino/)

**`bc-dev-ubuntu-22-04-lts`**

```auto
FROM ubuntu:22.04

MAINTAINER Takanobu Fuse <ficusonline@gmail.com>

# Configure locale
RUN apt-get update && \
    apt-get install -y locales && \
    apt-get clean && \
    echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
    locale-gen
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'
ENV TZ=Europe/Paris
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ARG DEBIAN_FRONTEND=noninteractive

ENV SHELL=/bin/bash
#ENV PS1='\[\e[33m\]\u@bc-dev-ubuntu-22-04-lts>\[\e[0m\] '

# Install common general tools
RUN apt-get update && \
    apt-get install -y nano sudo vim && \
    apt-get clean

# Install development tools
RUN apt-get update && \
    apt-get install -y alien at autoconf bison ccache clang cmake doxygen elfutils g++ gdb git graphviz intltool libtool lsb-release make nasm ninja-build openssh-client patch python3-pip python3-pystache python-six yasm && \
    apt-get clean

# Install linphone & flexisip dependencies development packages
RUN apt-get update && \
    apt-get install -y libasound2-dev libavcodec-dev libavutil-dev libbsd-dev libegl1-mesa-dev libglew-dev libgsm1-dev libjansson-dev libmariadb-dev-compat libmbedtls-dev libopus-dev libpq-dev libprotobuf-dev libpulse-dev libqt5svg5-dev libsnmp-dev libspeex-dev libspeexdsp-dev libsqlite3-dev libsrtp2-dev libssl-dev libswscale-dev libturbojpeg0-dev libv4l-dev libvpx-dev libxerces-c-dev libxml2-dev libxv-dev protobuf-compiler qt3d5-dev qtbase5-dev qtbase5-dev-tools qtchooser qt5-qmake qtconnectivity5-dev qtdeclarative5-dev qtdeclarative5-dev-tools qtdeclarative5-dev-tools qtquickcontrols2-5-dev qttools5-dev qttools5-dev-tools xsdcxx && \
    apt-get clean

# Configure user bc
RUN useradd -ms /bin/bash bc && \
    echo 'bc:cotcot' | chpasswd && \
    echo 'bc ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

USER bc
WORKDIR /home/bc
COPY --chown=bc rpmmacros /home/bc/.rpmmacros
CMD bash

```

**Makefikeの編集** （Ubuntu 22.04のセクション追加）

```auto
.....
.....
ubuntu-22.04-LTS:
	docker build -f bc-dev-ubuntu-22-04-lts -t $(BASE_NAME)/bc-dev-ubuntu:22.04 --rm .
.....
.....

```

**ビルド** （直接 **`docker build`** コマンドでビルドしても構いません）

```auto
$ make ubuntu-22.04-LTS

```

**Dockerイメージの確認**

```auto
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
gitlab.linphone.org:4567/bc/public/linphone-sdk/bc-dev-ubuntu 22.04 6ee9dee48674 47 minutes ago 2.28GB

```

任意のフォルダ（Linphoneまたはflexisipをビルドするフォルダ）内で上記イメージによるコンテナを起動

```auto
$ docker run --name linphone-sdk -v $PWD:/home/bc -it gitlab.linphone.org:4567/bc/public/linphone-sdk/bc-dev-ubuntu:22.04
bc@616cdfa4bb84:~$

```

### flexisipバイナリファイル

[Index of /snapshots](https://download.linphone.org/snapshots/)

[1. Installation - XWiki](https://wiki.linphone.org/xwiki/wiki/public/view/Flexisip/1.%20Installation/)

---

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2023 年 1 月 31 日午後 3:03 UTC](https://forum.ficusonline.com/t/topic/479/2 "2023-01-31T15:03:44Z")

</div>

## Linphone-Desktopのビルド

ホストマシンの環境に依存しない **AppImageフォーマット** でアプリを作成します。

> <https://askubuntu.com/questions/1403811/appimage-on-ubuntu-22-04>

Appimageの起動にlibfuse2ライブラリが必要です。  
Ubuntu22.04以降ではデフォルトでlibfuse2がインストールされていないため、インストールします。

```auto
$ sudo apt install libfuse2

```

> **[BC / public / linphone-desktop · GitLab](https://gitlab.linphone.org/BC/public/linphone-desktop)**
>
> Belledonne-Communications Gitlab

### Linphone-SDKコンテナの起動

上記投稿記事のイメージからコンテナを起動します。 **`FUSE`** を使用するための管理者権限オプションを付与する必要があります。

```auto
$ docker run --device /dev/fuse --cap-add SYS_ADMIN --security-opt apparmor:unconfined --name linphone-sdk -v $PWD:/home/bc -it gitlab.linphone.org:4567/bc/public/linphone-sdk/bc-dev-ubuntu:22.04

```

> <https://stackoverflow.com/questions/48402218/fuse-inside-docker>

> AppImages require **FUSE** version 2 to run. [Filesystem in Userspace (FUSE)](https://en.wikipedia.org/wiki/Filesystem_in_Userspace) is a system that lets non-root users mount filesystems.

> **[FUSE](https://github.com/AppImage/AppImageKit/wiki/FUSE)**
>
> Package desktop applications as AppImages that run on common Linux-based operating systems, such as RHEL, CentOS, openSUSE, SLED, Ubuntu, Fedora, debian and derivatives. Join #AppImage on irc.liber...

### `linphone-sdk` コンテナ内で以下のコマンドを実行

```auto
$ pip install pystache six
$ eval "$(qtchooser -print-env)"
$ export Qt5_DIR=${QTLIBDIR}/cmake/Qt5
$ export PATH=${QTTOOLDIR}:$PATH

```

### ビルドに必要な追加パッケージをインストール

```auto
$ sudo apt install wget fuse libfuse2
$ sudo apt install qml-module-qt-labs-folderlistmodel qml-module-qt-labs-platform qml-module-qt-labs-settings qml-module-qtgraphicaleffects qml-module-qtqml qml-module-qtqml-models2 qml-module-qtquick-controls qml-module-qtquick-controls2 qml-module-qtquick-dialogs qml-module-qtquick-layouts qml-module-qtquick-privatewidgets qml-module-qtquick-shapes qml-module-qtquick-templates2 qml-module-qtquick-window2 qml-module-qtquick2

```

* * *

**`qml-module`** については、以下のLinphone Desktop バグレポートも参照して下さい。

> **[\#978108 - linphone-desktop: doesn't start due to unmet dependencies - Debian...](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=978108)**

**Qtドキュメント**  
[https://doc.qt.io/](https://doc.qt.io/)

**QML Modules**  
[QML Modules | Qt QML 5.15.19](https://doc.qt.io/qt-5/qtqml-modules-topic.html)

**Qt Product Map**

> **[Qt Features, Framework Essentials, Modules, Tools & Add-Ons](https://www.qt.io/development/qt-framework/features)**
>
> See the features of the latest Qt version to see new functionality, which development platforms, operating systems and coding languages are supported.

**Qtオープンソース**

> **[Open Source Development | Open Source License | Qt](https://www.qt.io/development/download-open-source)**
>
> Learn how you can use the Qt framework under both open source and commercial licenses. Download Qt for open source development and get started today!

**ターミナルまたはスクリプトによりインストール**

> <https://askubuntu.com/questions/1404263/how-do-you-install-qt-on-ubuntu22-04>

```auto
$ sudo apt install -y qtcreator qtbase5-dev qt5-qmake cmake

```

> **[Download Qt | Get Qt Online Installer](https://www.qt.io/development/download-qt-installer)**
>
> Download Qt, a development tool containing everything you need for your entire software development life cycle. Install Qt today.

* * *

### ソースのダウンロード・Makeファイルの作成・ビルド

AppImageパッケージを出力するため **`-DENABLE_APP_PACKAGING=YES`** を指定

```auto
$ git clone https://gitlab.linphone.org/BC/public/linphone-desktop.git --recursive
$ cd linphone-desktop
$ mkdir build
$ cd build
$ cmake .. -DENABLE_APP_PACKAGING=YES -DCMAKE_BUILD_PARALLEL_LEVEL=10 -DCMAKE_BUILD_TYPE=RelWithDebInfo
$ cmake --build . --target install --parallel 10 --config RelWithDebInfo

```

**`RelWithDebInfo`**

> <https://stackoverflow.com/questions/48754619/what-are-cmake-build-type-debug-release-relwithdebinfo-and-minsizerel>

以下のディレクトリ・ファイル名でAppImageが作成されます。  
実行権は付与されているので、これを任意の場所へ移動してダブルクリックして起動します。  
**`build/OUTPUT/Packages/Linphone-5.1.0-alpha.40+e198f5f7.AppImage`**

 ![Screenshot from 2023-02-01 17-55-24](https://forum.ficusonline.com/uploads/default/original/2X/0/0621736c965526e0985ff03b0031efebfabfccf5.png)

シェルから起動することで各種ログを確認することが出来ます。

```auto
$ ./Linphone-5.1.0-alpha.40+e198f5f7.AppImage

```

下記も参照して下さい。

> [@Linphone-SDK Post Quantum media encryption](https://forum.ficusonline.com/t/topic/493/2):
>
> デスクトップ版LinphoneでPost Quantumオプションを有効化してビルド デスクトップ版Linphoneのビルドオプションについては下記テーブルを参照して下さい。AppImageによるパッケージをビルドします。AppImageによるアプリの動作条件は、Linuxディストリビューションに依存しないため、ビルド環境も、どのディストリビューションを利用しても構いません。 下記オプションの E…

---

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2023 年 2 月 2 日午後 1:25 UTC](https://forum.ficusonline.com/t/topic/479/3 "2023-02-02T13:25:39Z")

</div>

## Flexisipのビルド・DEBパッケージの作成

引き続き **`linphone-sdk`** コンテナを利用します。  
初めにコンテナ内で **`flexisip`** のソースと関連パッケージをダウンロードします。

```auto
$ git clone https://gitlab.linphone.org/BC/public/flexisip --recursive -b <branch_name>

```

Replace _\<branch\_name\>_ by one of the following:

- A release tag name if you want a specific release (e.g. “2.0.0”).
- A release branch name if you want a specific release plus all post release fixes (e.g. “release/2.0”)
- “master” if you want the development version.

次に `flexisip` のビルドに必要なパッケージを、以下ファイルを参考に追加インストール・ビルドインストールします。

**注）flexisipをビルドするための開発環境** は、`flexisip/docker`内のOS別Dockerfileからイメージを作成することでコンテナとして構築できます。

```auto
$ cd docker/container
$ docker build -f bc-dev-ubuntu-22-04 -t bc-dev-ubuntu:22-04 --rm .
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
bc-dev-ubuntu 22-04 6c4a54ac8b6a About an hour ago 1.94GB

```

プロジェクトフォルダーへ移動し上記イメージからコンテナ起動

```auto
$ cd ../../
$ docker run --name flexisip-sdk -v $PWD:/home/bc -it bc-dev-ubuntu:22-04

```

下記ビルドプロセスを実行します。

* * *

[https://gitlab.linphone.org/BC/public/flexisip/-/blob/master/docker/bc-dev-ubuntu-22-04](https://gitlab.linphone.org/BC/public/flexisip/-/blob/master/docker/bc-dev-ubuntu-22-04)

追加パッケージ

```auto
$ sudo apt install file llvm libboost-dev libboost-system-dev libboost-thread-dev libhiredis-dev libjsoncpp-dev mariadb-server libnghttp2-dev redis-server

```

追加ビルド・インストールパッケージ（スクリプトによりビルド・インストール）

```auto
$ cd flexisip/docker
$ sudo ./libnghttp2_asio_install.sh 1.43.0

```

上記の準備ができたら以下のフローで `flexisip` をビルドして下さい。

```auto
$ mkdir build
$ cd build
$ cmake .. -DCMAKE_INSTALL_PREFIX=/opt/belledonne-communications -DCMAKE_BUILD_TYPE=RelWithDebInfo -DSYSCONF_INSTALL_DIR=/etc -DCPACK_GENERATOR=DEB
$ make package

```

問題なければ以下2種類のパッケージが作成されます。

**`bc-flexisip_2.3.0-0.*_amd64.deb`**  
**`bc-flexisip-dbgsym_2.3.0-0.*_amd64.ddeb`**

* * *

### OS別flexisip公式レポジトリのインストール

CentOS, RockyLinux, Ubuntu, Debian対応。`flexisip`をビルドせずにレポジトリを登録し、新規に`flexisip`の`Docker`イメージを作成する場合は以下を参照して下さい。

> **[1. Installation - XWiki](https://wiki.linphone.org/xwiki/wiki/public/view/Flexisip/1.%20Installation/)**
>
> 1. Installation

## Supported distributions

| | CentOS 7 | RockyLinux 8 | RockyLinux 9 | Debian 8 (Jessie) | Debian 9 (Stretch) | Debian 10 (Buster) | Debian 11 (Bullseye) | Debian 12 (Bookworm) | Ubuntu 18.04 LTS (Bionic Beaver) | Ubuntu 22.04 LTS (Jammy Jellyfish) |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Flexisip 2.0 | ✓ | | | ✓ | ✓ | | | | ✓ | |
| Flexisip 2.1 | ✓ | | | | ✓ | ✓ | | | ✓ | |
| Flexisip 2.2 | ✓ | ✓ | | | Deprecated | ✓ | ✓ | | ✓ | ✓ |
| Flexisip 2.3 (beta) | Deprecated | ✓ | ✓ | | Deprecated | Deprecated | ✓ | ✓ | Deprecated | ✓ |
| Flexisip 2.4 (alpha) | Deprecated | ✓ | ✓ | | Deprecated | Deprecated | ✓ | ✓ | Deprecated | ✓ |

**`/etc/apt/sources.list.d/belledonne.list`**

```auto
# For Ubuntu 22.04 LTS
deb [arch=amd64] http://linphone.org/snapshots/ubuntu jammy stable # hotfix beta alpha

```

```bash
# For Ubuntu
$ wget https://www.linphone.org/snapshots/ubuntu/pubkey.gpg -O - | sudo apt-key add -
# Not doing this can result in the following error : "[SOCI] connection pool open error: Failed to find shared library for backend mysql"
$ sudo apt install libmariadb-dev
# Update & Install
$ sudo apt update
$ sudo apt install bc-flexisip

```

上記レポジトリを利用したイメージファイルを作成するためのDockerfile

`flex-from-ubuntu-apt-repo`

```auto
FROM ubuntu:22.04
MAINTAINER Takanobu Fuse <ficusonline@gmail.com>

# Prepare dependencies
RUN apt-get update
RUN apt-get install -y nano xsdcxx gdb libmariadb3 snmp-mibs-downloader snmp snmpd iproute2 iptables wget gnupg2
RUN echo 'deb [arch=amd64] http://linphone.org/snapshots/ubuntu jammy stable' > /etc/apt/sources.list.d/belledonne.list
RUN wget https://www.linphone.org/snapshots/ubuntu/pubkey.gpg -O - | apt-key add -
RUN apt-get update && apt-get install -y bc-flexisip

# Add it to the default path
ENV PATH=$PATH:/opt/belledonne-communications/bin

WORKDIR /opt/belledonne-communications

# Generate a default configuration
RUN flexisip --dump-default all > /etc/flexisip/flexisip.conf

VOLUME /etc/opt/belledonne-communications/flexisip
VOLUME /var/opt/belledonne-communications/log/flexisip
COPY flexisip-entrypoint.sh /
COPY backtrace.gdb /
RUN chmod a+x /flexisip-entrypoint.sh

# Script to wait db before launch flexisip [Licence Apache2]
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.2.1/wait /wait
RUN chmod +x /wait

ENTRYPOINT ["/flexisip-entrypoint.sh"]
CMD flexisip

```

上記Dockerfileからflexisipレポジトリを取り込んでflexisipをインストールしたイメージファイルを作成

```auto
$ docker build -f flex-from-ubuntu-apt-repo --pull --no-cache -t flex-from-ubuntu-apt-repo:22.04 --rm .

```

コンテナ起動

```auto
$ docker run -d --network host --name ubuntu-flexisip-repo flex-from-ubuntu-apt-repo:22.04 --server proxy

```

**参考）**

> <https://stackoverflow.com/questions/46406847/docker-how-to-add-backports-to-sources-list-via-dockerfile>

> <https://stackoverflow.com/questions/50757647/e-gnupg-gnupg2-and-gnupg1-do-not-seem-to-be-installed-but-one-of-them-is-requ>

---

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2023 年 2 月 4 日午前 10:00 UTC](https://forum.ficusonline.com/t/topic/479/4 "2023-02-04T10:00:10Z")

</div>

## Flexisip Dockerイメージの作成

前記事で作成した `flexisip` のパッケージを利用して `Flexisip Dockerイメージ` を作成します。

`deb,ddeb` パッケージを以下のフォルダにコピーして作業します。

 ![Screenshot from 2023-02-04 18-48-58](https://forum.ficusonline.com/uploads/default/original/2X/0/03b11ccd0face334b35f72f76b562b9962d7a970.png)

`flex-from-deb` を参考にUbuntu 22.04ベースのDockerfile `flex-from-ubuntu-deb` を作成しMakefileにビルドコマンドを追加します。（`snmp-mibs-downloader snmp snmpd` のインストールはオプション。SNMPによりflexisipの設定ファイル内の各セクションの設定事項の確認と書換えが行えます。）

**`flex-from-ubuntu-deb`**

```auto
FROM ubuntu:22.04
MAINTAINER Takanobu Fuse <ficusonline@gmail.com>

# Prepare dependencies
RUN apt-get update
RUN apt-get install -y nano xsdcxx gdb libmariadb3 snmp-mibs-downloader snmp snmpd iproute2

# Get flexisip package
COPY *.deb *.ddeb deb-packages/
RUN apt-get install -y /deb-packages/*
RUN rm -rf /deb-packages

# Add it to the default path
ENV PATH=$PATH:/opt/belledonne-communications/bin

WORKDIR /opt/belledonne-communications

# Generate a default configuration
RUN flexisip --dump-default all > /etc/flexisip/flexisip.conf

VOLUME /etc/opt/belledonne-communications/flexisip
VOLUME /var/opt/belledonne-communications/log/flexisip
COPY flexisip-entrypoint.sh /
COPY backtrace.gdb /
RUN chmod a+x /flexisip-entrypoint.sh

# Script to wait db before launch flexisip [Licence Apache2]
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.2.1/wait /wait
RUN chmod +x /wait

ENTRYPOINT ["/flexisip-entrypoint.sh"]
CMD flexisip

```

**`Makefile`** 注）追加部分のみ記載

```auto
.....
.....

# For Ubuntu 22.04
flexisip-ubuntu-deb-before:
	$(eval DOCKER_FILE = flex-from-ubuntu-deb)
	# forcing context to .
	# at the moment of the condition above being executed, $DOCKER_FILE doesn't have the right value
	$(eval CONTEXT = .)
	$(eval DOCKER_TAG = $(DOCKER_TAG)-deb)

.....
.....
.....

# For Ubuntu 22.04
flexisip-ubuntu-deb-build: flexisip-ubuntu-deb-before flexisip-build

flexisip-ubuntu-deb-push: flexisip-ubuntu-deb-before flexisip-push

flexisip-ubuntu-deb-clean: flexisip-ubuntu-deb-before flexisip-clean

.....

```

**ビルド**  
注）`flexisip-entrypoint.sh` の `"ulimit -c unlimited*"` を修正。'\*'を削除。

```auto
$ make flexisip-ubuntu-deb-build

```

**イメージファイルの確認**

```auto
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
gitlab.linphone.org:4567/bc/public/flexisip 2.3.0-alpha-29-gb19a1ce5-deb b3e1a47e3efd 9 hours ago 775MB

```

**コンテナ起動**  
設定ファイルを定義していないため、このイメージから起動できるのはプロキシモードのみとなります。設定ファイル `flexisip.conf` を出力するためプロキシモードでコンテナを起動して下さい。

```auto
$ docker run -d --network host --name ubuntu-flexisip <IMAGE_ID> --server proxy
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0fd6f8e90621 b3e1a47e3efd "/flexisip-entrypoin…" 9 hours ago Up 9 hours ubuntu-flexisip

```

**ログ確認**

```auto
$ docker logs ubuntu-flexisip
Flexisip docker params : flexisip --server proxy
--server param found, starting only one Flexisip instance

```

**設定ファイル `flexisip.conf` をコピー**

```auto
$ docker cp ubuntu-flexisip:/etc/flexisip/flexisip.conf ./

```

---

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2023 年 2 月 5 日午後 2:28 UTC](https://forum.ficusonline.com/t/topic/479/5 "2023-02-05T14:28:00Z")

</div>

## 設定ファイル : `flexisip.conf`

‼ **注）** `[conference-server], [b2bua-server]`の **outbound-proxy** のSIPアドレスを、`[global]`セクションの **transports** に必ず追加すること。

> [conference-server], [b2bua-server]  
> outbound-proxy=sip:127.0.0.1:7902;transport=tcp

> [global]  
> transports=sip:127.0.0.1:7902;transport=tcp …

**グローバル設定**

> **[global - XWiki](https://wiki.linphone.org/xwiki/wiki/public/view/Flexisip/A.%20Configuration%20Reference%20Guide/master/global)**
>
> global

`flexisip.conf`のセクションごとにポイントを纏めます。

**`[global]`**

```auto
user-errors-logs=true

transports=sip:ficus-home.duckdns.org:5060;maddr=172.16.0.6 sips:ficus-home.duckdns.org:5061;maddr=172.16.0.6

tls-certificates-file=/etc/letsencrypt/live/sip.example.com/fullchain.pem

tls-certificates-private-key=/etc/letsencrypt/live/sip.example.com/privkey.pem

tls-certificates-ca-file=/etc/letsencrypt/live/sip.example.com/cert.pem

```

**`[event-logs]`**

```auto
enabled=true

```

**`[presence-server]`**

```auto
rls-database-connection=db='flexisip_presence' user='flexisip' password='flexisip' host='flexisip-mariadb'

rls-database-max-thread=20

```

**`[conference-server]`**

```auto
conference-factory-uris=sip:conference-factory@ficus-home.duckdns.org

conference-focus-uris=

local-domains=ficus-home.duckdns.org

database-connection-string=db='flexisip_conference' user='flexisip' password='flexisip' host='flexisip-mariadb'

```

**`[regevent-server]`**

```auto
transport=sip:172.16.0.6:6065;transport=tcp

```

**`[b2bua-server]`** pending

```auto
#transport=sip:127.0.0.1:6067;transport=tcp

#outbound-proxy=sip:127.0.0.1:5060;transport=tcp

```

**`[b2bua-server::trenscrypter]`** pending

```auto
#outgoing-enc-regex=

#outgoing-srtp-regex=

```

**`[module::DoSProtection]`**

```auto
white-list=ficus-home.duckdns.org sip.linphone.org

```

**`[module::NatHelper]`**

```auto
# documentation here : https://wiki.linphone.org/xwiki/wiki/public/view/Flexisip/Configuration/Filter%20syntax/
# Default: 
filter=!(user-agent contains 'No NatHelper')

```

**`[module::Authentication]`**

```auto
enabled=true

#trusted-hosts=

auth-domains=ficus-home.duckdns.org localhost

available-algorithms=SHA-256 MD5

db-implementation=soci

soci-connection-string=db='flexisip' user='flexisip' password='flexisip' host='flexisip-mariadb'

soci-password-request=select passwords.password, passwords.algorithm from accounts inner join passwords on accounts.id=passwords.account_id where username = :id and domain = :domain

soci-poolsize=25

```

**`[module::RegEvent]`**

```auto
regevent-server=sip:172.16.0.6:6065;transport=tcp

```

**`[module::B2bua]`** pending

```auto
#enabled=false

# documentation here : https://wiki.linphone.org/xwiki/wiki/public/view/Flexisip/Configuration/Filter%20syntax/
#filter=

# A sip uri where to send all the relevent requests.
# Default: sip:127.0.0.1:6067;transport=tcp
#b2bua-server=sip:127.0.0.1:6067;transport=tcp

```

**`[module::Presence]`** pending

```auto
enabled=true

# A SIP URI where to send all presence related requests.
# Default: sip:127.0.0.1:5065;transport=tcp
#presence-server=sip:127.0.0.1:5065;transport=tcp

```

**`[module::Registrar]`**

```auto
reg-domains=ficus-home.duckdns.org localhost

db-implementation=redis

redis-server-domain=redis
 
redis-auth-password=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

```

**`[module::Router]`** pending

```auto
#message-database-enabled=false

#message-database-backend=mysql

#message-database-connection-string=db='mydb' user='myuser' password='mypass' host='myhost.com'

```

**`[module::MediaRelay]`**

```auto
# The minimal value of SDP port range
# Default: 1024
sdp-port-range-min=10000

# The maximal value of SDP port range
# Default: 65535
sdp-port-range-max=10050

```

**`[module::Forward]`**

```auto
route=<sip:172.16.0.6;transport=tcp>

```

* * *

### ワンドメインでの設定ファイル例

> **[Deploy Flexisip for one domain - XWiki](https://wiki.linphone.org/xwiki/wiki/public/view/Flexisip/HOWTOs/Deploy%20Flexisip%20for%20one%20domain/)**
>
> Deploy Flexisip for one domain

* * *

### SOCI

> **[SOCI (master)](https://soci.sourceforge.net/doc/master/)**
>
> SOCI - The C++ Database Access Library

# Supported Backends and Features

[Features - SOCI (master)](https://soci.sourceforge.net/doc/master/backends/#supported-backends-and-features)

Follow the links to learn more about each backend and detailed supported features.

| | [Oracle](https://soci.sourceforge.net/doc/master/backends/oracle/) | [PostgreSQL](https://soci.sourceforge.net/doc/master/backends/postgresql/) | [MySQL](https://soci.sourceforge.net/doc/master/backends/mysql/) | [SQLite3](https://soci.sourceforge.net/doc/master/backends/sqlite3/) | [Firebird](https://soci.sourceforge.net/doc/master/backends/firebird/) | [ODBC](https://soci.sourceforge.net/doc/master/backends/odbc/) | [DB2](https://soci.sourceforge.net/doc/master/backends/db2/) |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Binding by Name | YES | YES (≥8.0) | YES | YES | YES | YES | YES |
| Dynamic Binding | YES | YES | YES | YES | YES | YES | |
| Bulk Operations | YES | YES | YES | YES | YES | YES | YES |
| Transactions | YES | YES | YES (≥4.0) | YES | YES | YES | YES |
| BLOB Data Type | YES | YES | YES (mapped to `std::string`) | YES | YES | NO | NO |
| RowID Data Type | YES | YES | NO | NO | NO | NO | NO |
| Nested Statements | YES | NO | NO | NO | NO | NO | YES |
| Stored Procedures | YES | YES | NO (but stored functions, YES) | NO | YES | NO | YES |

---

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2023 年 2 月 7 日午前 5:16 UTC](https://forum.ficusonline.com/t/topic/479/6 "2023-02-07T05:16:50Z")

</div>

## SNMP (Simple Network Management Protocol)

> **[Simple Network Management Protocol](https://en.wikipedia.org/wiki/Simple_Network_Management_Protocol)**
>
> Simple Network Management Protocol (SNMP) is an Internet Standard protocol for collecting and organizing information about managed devices on IP networks and for modifying that information to change device behavior. Devices that typically support SNMP include cable modems, routers, network switches, servers, workstations, printers, and more.
> SNMP is widely used in network management for network monitoring. SNMP exposes management data in the form of variables on the managed systems organized ...

`flexisip`の設定ファイルで`snmp`を有効にした場合、`snmp`コマンドにより`flexisip`の設定事項の確認と書換えが行えます。必要なパッケージは **`snmp-mibs-downloader, snmp, snmpd`** の3つです。

**注）** 特に必要なければ、このオプションは無効のままで構いません。念の為、`Flexisip`の`Docker`イメージ作成時に上記パッケージを予めインストールしておきましょう。

下記`flexisip`の`snmp`を参考に `snmpd.conf` に必要な項目を追加・変更します。

> **[SNMP - XWiki](https://wiki.linphone.org/xwiki/wiki/public/view/Flexisip/Configuration/SNMP/)**
>
> SNMP

**追加・変更項目**

```auto
agentAddress udp:127.0.0.1:161
master agentx
agentXPerms 0660 0550 root root
rocommunity public localhost
rwcommunity private localhost

```

**`/etc/snmp/snmpd.conf`**

```auto
###########################################################################
#
# snmpd.conf
# An example configuration file for configuring the Net-SNMP agent ('snmpd')
# See snmpd.conf(5) man page for details
#
###########################################################################
# SECTION: System Information Setup
#

# syslocation: The [typically physical] location of the system.
# Note that setting this value here means that when trying to
# perform an snmp SET operation to the sysLocation.0 variable will make
# the agent return the "notWritable" error code. IE, including
# this token in the snmpd.conf file will disable write access to
# the variable.
# arguments: location_string
sysLocation Sitting on the Dock of the Bay
sysContact Me <me@example.org>

# sysservices: The proper value for the sysServices object.
# arguments: sysservices_number
sysServices 72

###########################################################################
# SECTION: Agent Operating Mode
#
# This section defines how the agent will operate when it
# is running.

# master: Should the agent operate as a master agent or not.
# Currently, the only supported master agent type for this token
# is "agentx".
#   
# arguments: (on|yes|agentx|all|off|no)

master agentx
agentXPerms 0660 0550 root root
# agentaddress: The IP address and port number that the agent will listen on.
# By default the agent listens to any and all traffic from any
# interface on the default SNMP port (161). This allows you to
# specify which address, interface, transport type and port(s) that you
# want the agent to listen on. Multiple definitions of this token
# are concatenated together (using ':'s).
# arguments: [transport:]port[@interface/address],...

agentaddress udp:127.0.0.1:161

###########################################################################
# SECTION: Access Control Setup
#
# This section defines who is allowed to talk to your running
# snmp agent.

# Views 
# arguments viewname included [oid]

# system + hrSystem groups only
view systemonly included .1.3.6.1.2.1.1
view systemonly included .1.3.6.1.2.1.25.1

# rocommunity: a SNMPv1/SNMPv2c read-only access community name
# arguments: community [default|hostname|network/bits] [oid | -V view]

# Read-only access to everyone to the systemonly view
rocommunity public localhost
rwcommunity private localhost

rocommunity public default -V systemonly
rocommunity6 public default -V systemonly

# SNMPv3 doesn't use communities, but users with (optionally) an
# authentication and encryption string. This user needs to be created
# with what they can view with rouser/rwuser lines in this file.
#
# createUser username (MD5|SHA|SHA-512|SHA-384|SHA-256|SHA-224) authpassphrase [DES|AES] [privpassphrase]
# e.g.
# createuser authPrivUser SHA-512 myauthphrase AES myprivphrase
#
# This should be put into /var/lib/snmp/snmpd.conf 
#
# rouser: a SNMPv3 read-only access username
# arguments: username [noauth|auth|priv [OID | -V VIEW [CONTEXT]]]
rouser authPrivUser authpriv -V systemonly

# include a all *.conf files in a directory
includeDir /etc/snmp/snmpd.conf.d

```

`snmp`デーモンの起動

```auto
# /etc/init.d/snmpd start

```

`flexisip`の`mib`の作成

> **[SNMP MIB](https://docs.oracle.com/cd/E13203_01/tuxedo/tux91/snmpmref/1tmib.htm)**
>
> BEA Tuxedo Documentation

```auto
# mkdir -p ~/.snmp/mibs
# flexisip --dump-mibs > ~/.snmp/mibs/fleximib.txt

```

`flexisip`の`mib`出力  
**注）** `flexisip.conf`内でコメントアウトしているデフォルト項目が全てアンコメントになります。

```sh
# snmpwalk -m FLEXISIP-MIB -v 2c -c public -Of localhost FLEXISIP-MIB::flexisipMIB
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.notif.msg.0 = ""
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.notif.source.0 = ""
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.runtimeError.0 = ""
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.versionNumber.0 = STRING: "2.3.0-alpha-29-gb19a1ce5"
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.dumpCorefiles.0 = INTEGER: false(0)
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.countIncomingResponse401.0 = Counter64: 0
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.countIncomingResponse603.0 = Counter64: 0
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.logDirectory.0 = STRING: "/var/opt/belledonne-communications/log/flexisip"
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.tlsCertificatesPrivateKey.0 = ""
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.countReply408.0 = Counter64: 0
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.maxLogSize.0 = STRING: "-1"
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.countReplyUnknown.0 = Counter64: 0
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.keepaliveInterval.0 = INTEGER: 1800
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.countIncomingRequestUnknown.0 = Counter64: 0
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.countReply101.0 = Counter64: 0
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.rtpBindAddress.0 = STRING: "0.0.0.0 ::0"
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.enableSnmp.0 = INTEGER: true(1)
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.syslogLevel.0 = STRING: "debug"
.......
.......
.......

```

上記の特定の項目のみ出力

```auto
# snmpget -m FLEXISIP-MIB -v 2c -c public -Of localhost FLEXISIP-MIB::flexisipMIB.flexisip.global.syslogLevel.0
.iso.org.dod.internet.private.enterprises.flexisipMIB.flexisip.global.syslogLevel.0 = STRING: "debug"

```

設定項目を変更（`systemlogLevel`を`debug`から`error`へ変更）

```auto
# snmpset -m FLEXISIP-MIB -v 2c -c private localhost FLEXISIP-MIB::flexisipMIB.flexisip.global.syslogLevel.0 s "error"

```

**YouTube SNMP Operation**

[![](https://forum.ficusonline.com/uploads/default/original/2X/0/04a74750308b884a06340c3b4701463d676c8997.jpeg "SNMP Operation (CCNA Complete Video Course Sample)") ](https://www.youtube.com/watch?v=tg47MZdtcAE)

> **[TUT:snmpset - Net-SNMP Wiki](https://www.net-snmp.org/wiki/index.php/TUT:snmpset)**

---

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2023 年 2 月 9 日午前 3:54 UTC](https://forum.ficusonline.com/t/topic/479/7 "2023-02-09T03:54:25Z")

</div>

## Certbot DockerコンテナによるSSL認証手続き

`flexisip`によるシステム運用にはSSL(TLS)認証は不可欠です。`Docker`コンテナにより事前に取得しておくことにより`nginx`や`flexisip`の設定に反映させて下さい。以下の記事も参照願います。

> [@Nginx+Let's Encrypt(Certbot) on Docker](https://forum.ficusonline.com/t/topic/375/9):
>
> NginxコンテナへのCertbotの導入についてbangbang Nginx公式イメージにCertbotを追加した新規イメージを作成し、コンテナ起動後にCertbotによる認証手続きを行うのではなく、事前にCertbotによるSSL認証手続きを専用のDockerイメージを利用してスタンドアローンモードで行い、取得した認証ファイルをdocker-composeファイル内で指定してNginxコ…

**Alternative 1: Docker**  
[Get Certbot — Certbot 5.4.0 documentation](https://eff-certbot.readthedocs.io/en/stable/install.html#alternative-1-docker)

**注）** `$PWD`はコマンドを実行するディレクトリ

```auto
$ docker run -it --rm --name certbot -v "$PWD/letsencrypt:/etc/letsencrypt" -p 80:80 certbot/certbot certonly --standalone -d www.example.com

```

**Setting up automated renewal**  
[User Guide — Certbot 5.4.0 documentation](https://eff-certbot.readthedocs.io/en/stable/using.html#setting-up-automated-renewal)

ホストマシンのクロンジョブに以下の`Certbot Docker`コンテナによる`renew`コマンドを追加  
**注）** ディレクトリには絶対パスを指定すること。

```auto
$ docker run -it --rm --name certbot -v "/??/??/.../letsencrypt:/etc/letsencrypt" -p 80:80 certbot/certbot renew

```

証明書の期限は90日のため **60日毎の更新手続き** を推奨しています。

**`flexisip.conf`** での設定は以下のようにします。

```auto
tls-certificates-file=/etc/letsencrypt/live/sip.example.com/fullchain.pem
tls-certificates-private-key=/etc/letsencrypt/live/sip.example.com/privkey.pem
tls-certificates-ca-file=/etc/letsencrypt/live/sip.example.com/cert.pem

```

---

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2023 年 3 月 25 日午後 2:21 UTC](https://forum.ficusonline.com/t/topic/479/8 "2023-03-25T14:21:38Z")

</div>

## flexisip-account-managerの導入

**`flexisip-account-manager`** （以下 **`fam`** ）のデザインは **`Laravel`** （PHPフレームワーク）によるものです。 **`Docker Compose`** ファイルで使用するサービスの一つとして、専用のイメージをビルドするための **`Docker`** ファイル : **`php-fpm-alpine-laravel`** を作成します。

`Composer`と`PHP`機能拡張のインストールには、[DockerHubのPHP公認ページ](https://hub.docker.com/_/php)が推奨している以下の **`docker-php-extension-installer`** を利用します。

[https://github.com/mlocati/docker-php-extension-installer](https://github.com/mlocati/docker-php-extension-installer)

**`php-fpm-alpine-laravel`**

```sh
FROM php:fpm-alpine

# Set working directory
WORKDIR /var/www/html

RUN apk add --no-cache bash nano libpng-dev freetype-dev libjpeg-turbo-dev libxml2-dev

# Install Composer and PHP extensions
RUN curl -sSLf \
        -o /usr/local/bin/install-php-extensions \
        https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \
    chmod +x /usr/local/bin/install-php-extensions && \
    install-php-extensions redis mysqli xmlrpc pdo_mysql @composer && \
    IPE_GD_WITHOUTAVIF=1 install-php-extensions gd

# Installing Laravel
RUN chown -R www-data:www-data /var/www/html
RUN composer global require laravel/installer \
    && ln -s /root/.config/composer/vendor/laravel/installer/bin/laravel /usr/local/bin/laravel

```

**ダウンロード：GitHub**  
[https://github.com/BelledonneCommunications/flexisip-account-manager](https://github.com/BelledonneCommunications/flexisip-account-manager)

---

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2023 年 3 月 25 日午後 2:34 UTC](https://forum.ficusonline.com/t/topic/479/9 "2023-03-25T14:34:24Z")

</div>

## Docker Composeファイル（IPv6対応）の作成

**`docker-compose.yml`**

```yaml
version: '3.5'

services:
##### redis-server
  redis:
    container_name: redis
    image: redis:alpine
    volumes:
        - ./redis:/etc/redis
    # need to download default config file:redis.conf from https://redis.io/topics/config
    # then modify it to enable the auth access(password), and input it into /redis/etc directory.
    command: ["redis-server", "/etc/redis/redis.conf"]
    privileged: true
    restart: always
    networks: 
      proxy-tier:

##### nginx
  nginx:
    container_name: nginx
    image: nginx:alpine
    tty: true
    ports:
      - "80:80"
      - "443:443"
    volumes:
      # nginx config
      - ./nginx:/etc/nginx/conf.d
      # certbot letsencrypt certification. Created by docker_hub certbot/certbot
      # $ docker run -it --rm --name certbot -v "$PWD/letsencrypt:/etc/letsencrypt" -p 80:80 certbot/certbot certonly --standalone -d www.example.com
      # Add the below cronjob into the host crontab.
      # docker run -it --rm --name certbot -v "/??/??/.../letsencrypt:/etc/letsencrypt" -p 80:80 certbot/certbot renew
      - ./letsencrypt:/etc/letsencrypt
      # shared the directory /flexisip-account-manager in php-fpm-laravel container
      - ./flexisip-account-manager/flexiapi:/var/www/html/flexiapi
      # shared the directory /var/www/html in phpmysql-fpm container
      - phpmyadmin:/var/www/html/phpmyadmin
    restart: always
    networks: 
      proxy-tier:     

##### mariadb
  flexisip-mariadb:
    container_name: flexisip-mariadb
    image: mariadb
    restart: always
    volumes:
      - ./db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_DATABASE=${MYSQL_DATABASE}
      - MYSQL_USER=${MYSQL_USER}
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
    networks: 
      proxy-tier:

### flexisip
  ubuntu-flexisip:
    container_name: ubuntu-flexisip
    image: gitlab.linphone.org:4567/bc/public/flexisip:2.3.0-alpha-29-gb19a1ce5-deb  
    volumes:
      - ./letsencrypt:/etc/letsencrypt
      # previously need to add "flexisip" directory and input "flexisip.conf" into it.
      - ./flexisip_conf:/etc/flexisip
      # for conference server linphone db directory
      - ./linphone:/root/.local/share/linphone
    extra_hosts:
      - "sip.example.com:192.168.xx.xx"
    depends_on:
      - redis
      - nginx
      - flexisip-mariadb
    restart: always
    # https://github.com/BelledonneCommunications/flexisip/blob/master/docker/flexisip-entrypoint.sh
    # for starting only "proxy" server
    command: ["--server","proxy"]
    # for starting "proxy, presence, conference" servers
    #command: [""]
        ## allow the privilege of network to the container
    cap_add:
      - NET_ADMIN
      - SYS_RESOURCE
    network_mode: "host"
    
##### phpmyadmin-fpm
  phpmyadmin-fpm:
    container_name: phpmyadmin-fpm
    image: phpmyadmin/phpmyadmin:fpm-alpine
    tty: true
    expose: 
      - "9000"
    environment:
      - PMA_HOST=flexisip-mariadb
      - PMA_PORT=3306
      - PMA_ABSOLUTE_URI=http://localhost/phpmyadmin
    volumes:
      - phpmyadmin:/var/www/html
      - /sessions
    depends_on:
      - flexisip-mariadb
    restart: always
    networks: 
      proxy-tier:
        
##### php-fpm-laravel
  php-fpm-laravel:
    container_name: php-fpm-laravel
    build: 
      context: ./docker_files
      dockerfile: php-fpm-alpine-laravel      
    tty: true
    expose: 
      - "9000"
    # "php artisan serve" commmand default port
    ports:
      - 8000:8000
    volumes:
      # for laravel php framework
      - ./flexisip-account-manager/flexiapi:/var/www/html/flexiapi
      # provisioning config
      - ./xmlrpc:/opt/belledonne-communications/share/flexisip-account-manager/xmlrpc
      # Flexisip-account-manager log
      - ./log:/var/opt/belledonne-communications/log
    depends_on:
      - ubuntu-flexisip
    restart: always
    networks: 
      proxy-tier:

networks:
  proxy-tier:
    name: containers-network-ipv6
    external: true

### $ docker volume create phpmyadmin  
volumes:
  phpmyadmin:
    external: true

```

* * *

**備 考）**

- Dockerネットワークと`phpmyadmin`ボリュームは予め作成すること。

- `redis`設定ファイルは上記記述したサイトからダウンロードして下さい。  
`bind`にはコンテナに割当てられるIPも追加してください。

- `mariadb` で定義するデータベース名、ユーザ名、パスワードは **`.env`** ファイルで明示して下さい。

- `flexisip`の **`command: [""]`** は`proxy`サーバだけを起動する場合には **`command: ["--server", "proxy"]`** とします。指定しない場合には、 **`proxy, presence, conference`** の3サーバが同時に起動します。

- ‼ **重要）** `flexisip`コンテナの **ネットワークにはホストを指定** します。`RTP`用に常時ある程度多いポート数を確保する必要があるため、ここをブリッジとすると全体のパフォーマンスが大きく低下します。

- ‼ **重要）** `flexisip`コンテナ内でドメイン名とローカルIPアドレスを紐付けます（`/etc/hosts`へ登録）。これを行わないとSIP接続が迷走します。

- `TLS`認証は`Cerbot`コンテナで`flexisip`を起動する前に行います。

* * *

## システム起動後のコンテナ内での操作

**`php-fpm-laravel`** コンテナ内で以下の作業を行います。

[https://github.com/BelledonneCommunications/flexisip-account-manager#console-commands](https://github.com/BelledonneCommunications/flexisip-account-manager#console-commands)

```bash
$ docker compose exec php-fpm-laravel sh
# cd flexiapi

```

① **`flexisip-account-manager`** に必要な依存パッケージのダウンロード

```sh
# composer install --no-dev

```

② **`.env`** ファイルを作成しセキュリティキーを適用。認証用SMTPメールサーバ、データベースなどの設定を **`.env`** ファイル内で行います。

```auto
# cp .env.example .env
# php artisan key:generate

```

③ **`Linphone`** のアカウント用データベースを作成します。

```auto
# php artisan migrate

```

④ サイトディレクトリの所有者を`www-data`へ変更し、ウェブフロントエンドからユーザ登録します。

```auto
# chown -R www-data:www-data ./
# find /var/www/html/flexiapi -type f -exec chmod 644 {} \;
# find /var/www/html/flexiapi -type d -exec chmod 755 {} \;

```

 ![ficus-home.myvnc.com_register_email](https://forum.ficusonline.com/uploads/default/original/2X/a/aa7744896a8065f53aed70c0e8c68a8354dbfd84.png)

⑤ 管理者ユーザの設定。登録したユーザを **`flexisip-account-manager`** の管理者とします。

```auto
# php artisan accounts:set-admin {account_id}

```

**Note)**

```auto
# php artisan --help
# php artisan cache:clear

```

* * *

**注）** フロントエンドは **`Laravel`** で作成された **`flexisip-accont-manager/flexiapi`** ディレクトリで構成されています（ **`flexisip-accont-manager/xmlrpc`** ディレクトリは必要はありません）。

設定ファイルは **`flexisip-accont-manager/flexiapi/config`** ディレクトリに格納されています。この設定ファイルの変数を上書きするために **`.env`** ファイルが利用されます。

---

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2023 年 3 月 26 日午前 3:56 UTC](https://forum.ficusonline.com/t/topic/479/10 "2023-03-26T03:56:28Z")

</div>

## エラー対応

`conference`サーバ起動時のエラーログ

```auto
2023-03-26 02:42:39:281 liblinphone-error-Could not find a suitable soundcard with capabilities : 2
2023-03-26 02:42:39:281 liblinphone-error-Could not find a suitable soundcard with capabilities : 2
2023-03-26 02:42:39:281 liblinphone-error-Could not find a suitable soundcard with capabilities : 1
2023-03-26 02:42:39:281 liblinphone-error-Could not find a suitable soundcard with capabilities : 2
2023-03-26 02:42:39:328 bctbx-error-bctbx_file_open: Error open No such file or directory
2023-03-26 02:42:39:328 liblinphone-error-Error in the opening zrtp_cache_db_file(/root/.local/share/linphone/zrtp-secrets.db): unable to open database file.

```

* * *

**① ハードウェア（サウンドカード）認識エラー**

> liblinphone-error-Could not find a suitable soundcard with capabilities

Docker Composeファイルにデバイスオプション追加—\>検証中—\>現状グループチャットのみの対応であることと、参加者の中継サーバとしての機能のため`soundcard`は不必要。エラー表示のバグ？

デバックモードで確認  
原因：プラグインエラー

```auto
2023-04-06 13:15:10:876 mediastreamer-message-Loading ms plugins from [/opt/belledonne-communications/lib/mediastreamer/plugins]
2023-04-06 13:15:10:876 mediastreamer-message-Cannot open directory /opt/belledonne-communications/lib/mediastreamer/plugins: No such file or directory
2023-04-06 13:15:10:876 liblinphone-error-Could not find a suitable soundcard with capabilities : 2
2023-04-06 13:15:10:876 liblinphone-error-Could not find a suitable soundcard with capabilities : 2
2023-04-06 13:15:10:876 liblinphone-error-Could not find a suitable soundcard with capabilities : 1
2023-04-06 13:15:10:876 liblinphone-error-Could not find a suitable soundcard with capabilities : 2

```

[https://github.com/BelledonneCommunications/flexisip/issues/158](https://github.com/BelledonneCommunications/flexisip/issues/158)

* * *

**② `sqlite3`データベース作成エラー**

> bctbx-error-bctbx\_file\_open: Error open No such file or directory  
> liblinphone-error-Error in the opening zrtp\_cache\_db\_file(/root/.local/share/linphone/zrtp-secrets.db): unable to open database file.

以下参照し、新規にディレクトリを作成  
[https://github.com/BelledonneCommunications/linphone-desktop/issues/268](https://github.com/BelledonneCommunications/linphone-desktop/issues/268)

イメージ作成時に以下のコマンドを追加。

```auto
# mkdir -p /root/.local/share/linphone

```

またはDocker Composeファイルにボリューム追加。

```auto
Volumes:
  # for conference server linphone db directory
  - ./linphone:/root/.local/share/linphone

```

---

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2023 年 3 月 28 日午前 4:57 UTC](https://forum.ficusonline.com/t/topic/479/11 "2023-03-28T04:57:02Z")

</div>

## flexisip-account-manager表示エラー

ログイン前の各ページの幅縮小表示で上部メニューバーが隠れてしまう不具合

**修正前**

 ![ficus-home.myvnc.com_main_error](https://forum.ficusonline.com/uploads/default/original/2X/c/cf95b747a0352d3f3512cadd4660fa91a0b98272.png)

以下該当するメインページのクラス指定を **`navbar-expand-lg`** から **`navbar-expand`** へ変更

**`flexiapi/resources/views/layouts/main.blade.php`**

```auto
@if (config('app.web_panel'))
    <nav class="navbar navbar-expand">
        <div class="collapse navbar-collapse" >

```

**修正後**

 ![ficus-home.myvnc.com_main_fixed](https://forum.ficusonline.com/uploads/default/original/2X/a/ad0149bf14a8ba937f315be104b0c0a7e81e7895.png)

---

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2023 年 3 月 29 日午後 3:25 UTC](https://forum.ficusonline.com/t/topic/479/12 "2023-03-29T15:25:34Z")

</div>

## プロビジョニング

[https://wiki.linphone.org/xwiki/wiki/public/view/Lib/Features/Remote%20Provisioning/](https://wiki.linphone.org/xwiki/wiki/public/view/Lib/Features/Remote%20Provisioning/)

INIフォーマットまたはXMLフォーマットによる設定ファイルリスト(Android)

> **[linphone-android/app/src/main/assets at master ·...](https://github.com/BelledonneCommunications/linphone-android/tree/master/app/src/main/assets)**
>
> Linphone.org mirror for linphone-android (https://gitlab.linphone.org/BC/public/linphone-android) - BelledonneCommunications/linphone-android

### デフォルトのプロビジョニングファイルの設定

プロビジョニングファイル **`default.rc`** を作成し、 **`.env`** ファイルで指定します。

**`fleiapi/.env`**

```auto
# Account provisioning
ACCOUNT_PROVISIONING_RC_FILE=/opt/belledonne-communications/share/flexisip-account- 
manager/xmlrpc/default.rc
ACCOUNT_PROVISIONING_OVERWRITE_ALL=true

```

**ex) `default.rc`**

```auto
#
#This file shall not contain path referencing package name, in order to be portable when app is renamed.
#Paths to resources must be set from LinphoneManager, after creating LinphoneCore.

[sip]
default_proxy=0

[proxy_0]
avpf=1
avpf_rr_interval=1
dial_escape_plus=0
publish=1
reg_expires=31536000
reg_proxy="sip:sip.example.com;transport=tls"
reg_route="sip:sip.example.com;transport=tls"
realm=sip.example.com
conference_factory_uri=sip:conference-factory@sip.example.com

[nat_policy_0]
stun_server=sip.example.com:3478
protocols=stun,ice

[assistant]
domain=sip.example.com
xmlrpc_url=https://sip.example.com/provisioning

[lime]
enabled=0

```

Linphoneのアシスタント—\>”リモート設定を取得”に入力して、以下のURLを入力・適用することでLinphoneの基本設定を上書き出来ます。

または、管理者から付与されたQRコードを読み込むことで、Linphoneでのユーザ登録を自動的に行うことが可能です。

**`https://sip.example.com/provisioning`**

以下はユーザ登録するためのプロビジョニングサンプルデータです。

**`https://www.linphone.org/remote_provisioning.xml`**

```auto
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://www.linphone.org/xsds/lpconfig.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.linphone.org/xsds/lpconfig.xsd lpconfig.xsd">
  <section name="sip">
    <entry name="default_proxy" overwrite="true">0</entry>
  </section>
  <section name="net">
    <entry name="nat_policy_ref" overwrite="true">~OuCpkaPzCwyvMo</entry>
  </section>
  <section name="misc">
    <entry name="transient_provisioning" overwrite="true">1</entry> <!-- apply remote provisioning only once-->
  </section>
  <section name="nat_policy_default_values">
    <entry name="stun_server">stun.linphone.org</entry>
    <entry name="protocols">stun,ice</entry>
  </section>
  <section name="nat_policy_0">
    <entry name="ref" overwrite="true">~OuCpkaPzCwyvMo</entry>
    <entry name="stun_server" overwrite="true">stun.linphone.org</entry>
    <entry name="protocols" overwrite="true">stun,ice</entry>
  </section>
  <section name="auth_info_0" overwrite="true">
    <entry name="username" overwrite="true">bilbo.baggins</entry>
    <entry name="ha1" overwrite="true">7f37aeccfad9855e4584c5465d6b4638</entry>
    <entry name="realm" overwrite="true">sip.linphone.org</entry>
    <entry name="domain" overwrite="true">sip.linphone.org</entry>
    <entry name="algorithm" overwrite="true">MD5</entry>
  </section>
  <section name="proxy_0" overwrite="true">
    <entry name="reg_proxy" overwrite="true">&lt;sip:sip.linphone.org;transport=tls&gt;</entry>
    <entry name="reg_route" overwrite="true">&lt;sip:sip.linphone.org;transport=tls&gt;</entry>
    <entry name="reg_identity" overwrite="true">"Bilbo Baggins" &lt;sip:bilbo.baggins@sip.linphone.org&gt;</entry>
    <entry name="realm" overwrite="true">sip.linphone.org</entry>
    <entry name="quality_reporting_collector" overwrite="true">sip:voip-metrics@sip.linphone.org;transport=tls</entry>
    <entry name="quality_reporting_enabled" overwrite="true">1</entry>
    <entry name="quality_reporting_interval" overwrite="true">180</entry>
    <entry name="reg_expires" overwrite="true">31536000</entry>
    <entry name="reg_sendregister" overwrite="true">1</entry>
    <entry name="publish" overwrite="true">1</entry>
    <entry name="avpf" overwrite="true">1</entry>
    <entry name="avpf_rr_interval" overwrite="true">1</entry>
    <entry name="nat_policy_ref" overwrite="true">~OuCpkaPzCwyvMo</entry>
  </section>
</config>

```

#### ユーザ登録プロビジョニングデモ

[![](https://forum.ficusonline.com/uploads/default/original/2X/b/b702b116c1b0d6de571c0f4f38e2a89bf29d67bb.jpeg "Linphone provisioning at the customised SIP URL.") ](https://www.youtube.com/watch?v=VRSBuJvhlyA)

---

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2023 年 3 月 31 日午前 7:03 UTC](https://forum.ficusonline.com/t/topic/479/13 "2023-03-31T07:03:06Z")

</div>

## [Flexisip firewall rules - XWiki](https://wiki.linphone.org/xwiki/wiki/public/view/Flexisip/Configuration/Flexisip%20firewall%20rules/)

First, create a specific chain for Flexisip rules.

```auto
# iptables -N flexisip-input-rules

```

**UDP/TCP on port 5060**

```auto
# iptables -A flexisip-input-rules -p udp -m udp --dport 5060 -j ACCEPT

```

**TLS on port 5061**

```auto
# iptables -A flexisip-input-rules -p tcp -m tcp --dport 5061 -j ACCEPT

```

**STUN on port 3478**

```auto
# iptables -A flexisip-input-rules -p udp -m udp --dport 3478 -j ACCEPT

```

**RTP (if media relay is enabled)**

```auto
# iptables -A flexisip-input-rules -p udp -m udp --dport 10000:20000 -j ACCEPT

```

And then, add the new table into the **INPUT** chain, either by adding it at the end:

```auto
# iptables -A INPUT -j flexisip-input-rules

```

or by inserting just before a given rule:

**inserting before the fourth rules**

```auto
# iptables -I INPUT 4 -j flexisip-input-rules

```

---

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2023 年 3 月 31 日午後 2:36 UTC](https://forum.ficusonline.com/t/topic/479/14 "2023-03-31T14:36:33Z")

</div>

## IPv6アドレスによるメディアリレイ

> **[Outgoing RTP over IPv6?](https://community.asterisk.org/t/outgoing-rtp-over-ipv6/93055)**
>
> I would like to exclusively use IPv6 on my Asterisk server. Clients will all be Android devices connecting via mobile phone networks that provide IPv6 service. So, this is the only transport I defined in pjsip.conf \[transport-udp-ipv6\] ...

> **[MediaRelay - XWiki](https://wiki.linphone.org/xwiki/wiki/public/view/Flexisip/A.%20Configuration%20Reference%20Guide/master/module/MediaRelay)**
>
> MediaRelay

音声ビデオ通話に関わる設定は以下のモジュールが担います。一人のクライアントで音声2ポート、ビデオ2ポートを消費します。2者間ビデオ通話で合計8ポートが必要です。IPv6でこれを割り当てるためには、クライアント側でICEを有効にする必要があります。

```auto
[module::MediaRelay]

# Indicate whether the module is activated.
# Default: true
enabled=true

# A request/response enters module if the boolean filter evaluates
# to true. Ex: from.uri.domain contains 'sip.linphone.org', from.uri.domain
# in 'a.org b.org c.org', (to.uri.domain in 'a.org b.org c.org')
# && (user-agent == 'Linphone v2'). You can consult the full filter
# documentation here : https://wiki.linphone.org/xwiki/wiki/public/view/Flexisip/Configuration/Filter%20syntax/
# Default: 
#filter=

# The name of the SDP attribute to set by the first proxy to forbid
# subsequent proxies to provide relay. Use 'disable' to disable.
# Default: nortpproxy
#nortpproxy=nortpproxy

# The minimal value of SDP port range
# Default: 1024
sdp-port-range-min=1024

# The maximal value of SDP port range
# Default: 65535
sdp-port-range-max=65535

# Sends a ACK and BYE to 200Ok for INVITEs not belonging to any
# established call. This is to solve the race condition that happens
# when two callees answer the same call at the same time. According
# to RFC3261, the caller is expected to send an ACK followed by
# a BYE to the loser callee. This is not the case in RFC2543, where
# the proxy was supposed to do this. When set to true, the MediaRelay
# module will implement the RFC2543 behavior. Note that it may sound
# inappropriate to bundle this property with the media relay feature.
# However the MediaRelay module is the only one in Flexisip that
# has the visibility of SIP dialogs, which is necessary to implement
# this feature.
# Default: false
#bye-orphan-dialogs=false

# Maximum concurrent calls processed by the media-relay. Calls arriving
# when the limit is exceed will be rejected. A value of 0 means
# no limit.
# Default: 0
#max-calls=0

# When true, the 'c=' line and port number are set to the relay
# ip/port even if ICE candidates are present in the request, while
# the standard behavior is to leave the c= line and port number
# as they are in the original offer sent by the client. This variation
# allows callees that do not support ICE at all to benefit from
# the media relay service.
# Default: true
force-relay-for-non-ice-targets=false

# Prevent media-relay ports to loop between them, which can cause
# 100% cpu on the media relay thread. You need to set this property
# to false if you are running test calls from clients running on
# the same IP address as the flexisip server
# Default: true
#prevent-loops=true

# In case multiples '183 Early media' responses are received for
# a call, only the first one will have RTP streams forwarded back
# to caller. This feature prevents the caller to receive 'mixed'
# streams, but it breaks scenarios where multiple servers play early
# media announcement in sequence.
# Default: true
#early-media-relay-single=true

# Maximum number of relayed early media streams per call. This is
# useful to limit the cpu usage due to early media relaying on embedded
# systems. A value of 0 stands for unlimited.
# Default: 0
#max-early-media-per-call=0

# Period of time in seconds, after which a relayed call without
# any activity is considered as no longer running. Activity counts
# RTP/RTCP packets exchanged through the relay and SIP messages.
# Default: 3600
#inactivity-period=3600

# Force the media relay to use the public address of Flexisip to
# relay calls. It not enabled, Flexisip will deduce a suitable IP
# address by basing on data from SIP messages, which could fail
# in tricky situations e.g. when Flexisip is behind a TCP proxy.
# Default: false
force-public-ip-for-sdp-masquerading=true

```

[RFC 4566: SDP: Session Description Protocol](https://www.rfc-editor.org/rfc/rfc4566)

### Connection Data (“c=”)

```
  c=<nettype> <addrtype> <connection-address>

```

> The “c=” field contains connection data.
> 
> A session description MUST contain either at least one “c=” field in  
> each media description or a single “c=” field at the session level.  
> It MAY contain a single session-level “c=” field and additional “c=”  
> field(s) per media description, in which case the per-media values  
> override the session-level settings for the respective media.

---

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2023 年 4 月 6 日午後 2:14 UTC](https://forum.ficusonline.com/t/topic/479/15 "2023-04-06T14:14:03Z")

</div>

## `Presence`サーバ、`Conference`サーバのデバック

**`docker compose`** ファイル内の`ubuntu-flexisip`の `cmd`オプションで **`"--server proxy"`** を指定して`proxy`のみを起動してから、コンテナ`ubuntu-flexisip`内で下記サーバのいずれかを **`--debug`** オプションを指定して起動。各サーバの動作を確認。

**注）** どちらもポート`(5065, 6064)`も外部（インターネット）に開放する必要はありません。

### Presence server

> **[1. Presence server - XWiki](https://wiki.linphone.org/xwiki/wiki/public/view/Flexisip/C.%20Features/Presence%20server/)**
>
> 1. Presence server

```auto
$ docker compose exec ubuntu-flexisip bash
# flexisip --server presence --debug
......
......
......

```

### Conference server

> **[2. Conference server - XWiki](https://wiki.linphone.org/xwiki/wiki/public/view/Flexisip/C.%20Features/Conference%20server/)**
>
> 2. Conference server

```auto
$ docker compose exec ubuntu-flexisip bash
# flexisip --server conference --debug
......
......
......

```

* * *

[https://github.com/BelledonneCommunications/flexisip/issues/104](https://github.com/BelledonneCommunications/flexisip/issues/104)

---

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2023 年 4 月 11 日午前 11:52 UTC](https://forum.ficusonline.com/t/topic/479/16 "2023-04-11T11:52:45Z")

</div>

## Update Flexisip Server on Ubuntu 22.04 with Docker Compose Containers

[https://github.com/capitalfuse/docker-flexisip](https://github.com/capitalfuse/docker-flexisip)

 ![docker-flexisip-system](https://forum.ficusonline.com/uploads/default/original/2X/6/63d780b4d6fbd5f0fd6b036e8958b721e8868ad5.png)

---

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2023 年 4 月 24 日午前 7:40 UTC](https://forum.ficusonline.com/t/topic/479/17 "2023-04-24T07:40:19Z")

</div>

## Vonage SMS

#### SMS Notifications

> **[SMS Notifications - Notifications | Laravel 12.x - The clean stack for Artisans...](https://laravel.com/docs/10.x/notifications#sms-notifications)**
>
> In addition to support for sending email, Laravel provides support for sending notifications across a variety of delivery channels, including email, SMS (via Vonage, formerly known as Nexmo), and Slack. In addition, a variety of community built...

#### Laravel Vonage Notification Channel

[https://github.com/laravel/vonage-notification-channel](https://github.com/laravel/vonage-notification-channel)

### LaravelのデフォルトSMS送信ベンダー

アカウント取得（2ユーロまでのトライアルSMS送信サービス付き。トライアルではクレジットカードの登録は必要ありません）

> **[Vonageのビジネス](https://www.vonagebusiness.jp/)**
>
> Vonageは、ユニファイドコミュニケーション、コンタクトセンター、コミュニケーションAPIへ、柔軟でスケーラブルな音声、メッセージ、ビデオ、データ機能を提供します。

登録するとAPIキーとAPIシークレットが付与されるので、これを **`.env`** ファイルに記載します。

**`.env`**

```auto
# Vonage SMS API
VONAGE_KEY=xxxxxxxxxx
VONAGE_SECRET=xxxxxxxxxxxxxxx
VONAGE_SMS_FROM=1234567890 （トライアルでは任意の番号）

```

必要なパッケージを **`composer`** によりインストール

```s
# composer require laravel/vonage-notification-channel

```

**`Notification`** クラスを拡張したSMS送信メッセージ用新規クラス **`VonageSMS`** の作成

```s
# php artisan make:notification VonageSMS

```

**新規ファイル**

> `app/Notifications/VonageSMS.php`

```auto
<?php

namespace App\Notifications;

use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\VonageMessage;

class VonageSMS extends Notification
{

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct(private string $validateMessage)
    {
        //
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param mixed $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return ['vonage'];
    }

    /**
     * Get the Vonage / SMS representation of the notification.
     *
     * @param mixed $notifiable
     * @param mixed $alias
     * @return \Illuminate\Notifications\Messages\VonageMessage
     */
    public function toVonage($notifiable)
    {
        return (new VonageMessage())
            ->content($this->validateMessage);
    } 

    /**
     * Get the array representation of the notification.
     *
     * @param mixed $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            //
        ];
    }
}

```

**内容追加・書換ファイル**

> `app/Alias.php`

```auto
namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;

class Alias extends Model
{
    use Notifiable;
    protected $table = 'aliases';
    public $timestamps = false;

    public function account()
    {
        return $this->belongsTo('App\Account');
    }

    public function routeNotificationForVonage($notification)
    {
        return $this->alias;
    }
}

```

> `app/PhoneChangeCode.php`

```auto
namespace App;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;

class PhoneChangeCode extends Model
{
    use Notifiable;
    use HasFactory;

    public function account()
    {
        return $this->belongsTo('App\Account');
    }

    public function routeNotificationForVonage($notification)
    {
        return $this->phone;
    }

}

```

> `app/Http/Controllers/Account/RegisterController.php`

```auto
.....
.....
// use App\Libraries\OvhSMS;
use App\Notifications\VonageSMS;
.....
.....
        //$ovhSMS = new OvhSMS;
        //$ovhSMS->send($request->get('phone'), 'Your ' . config('app.name') . ' validation code is ' . $account->confirmation_key);
        //$alias->notify(new VonageSMS('Your ' . config('app.name') . ' validation code is ' . $account->confirmation_key));
        Notification::send($alias, new VonageSMS('Your ' . config('app.name') . ' validation code is ' . $account->confirmation_key));
.....
.....

```

> `app/Http/Controllers/Account/AuthenticateController.php`

```auto
.....
.....
// use App\Libraries\OvhSMS;
use App\Notifications\VonageSMS;
.....
.....
        // $ovhSMS = new OvhSMS;
        // $ovhSMS->send($request->get('phone'), 'Your ' . config('app.name') . ' validation code is ' . $account->confirmation_key);
        // $alias->notify(new VonageSMS('Your ' . config('app.name') . ' validation code is ' . $account->confirmation_key));
        Notification::send($alias, new VonageSMS('Your ' . config('app.name') . ' validation code is ' . $account->confirmation_key));
.....
.....

```

> `app/Http/Controllers/Api/AccountController.php`

```auto
.....
.....
// use App\Libraries\OvhSMS;
use App\Notifications\VonageSMS;
.....
.....
            // $ovhSMS = new OvhSMS;
            //$ovhSMS->send($request->get('phone'), 'Your ' . config('app.name') . ' recovery code is ' . $account->confirmation_key);
            // $alias->notify(new VonageSMS('Your ' . config('app.name') . ' validation code is ' . $account->confirmation_key));
            Notification::send($alias, new VonageSMS('Your ' . config('app.name') . ' validation code is ' . $account->confirmation_key));
.....
.....
        // $ovhSMS = new OvhSMS;
        // $ovhSMS->send($request->get('phone'), 'Your ' . config('app.name') . ' recovery code is ' . $account->confirmation_key);
        // $alias->notify(new VonageSMS('Your ' . config('app.name') . ' validation code is ' . $account->confirmation_key));
        Notification::send($alias, new VonageSMS('Your ' . config('app.name') . ' validation code is ' . $account->confirmation_key));
.....
.....

```

> `app/Http/Controllers/Api/AccountPhoneController.php`

```auto
.....
.....
// use App\Libraries\OvhSMS;
use App\Notifications\VonageSMS;
.....
.....
        // $ovhSMS = new OvhSMS;
        // $ovhSMS->send($request->get('phone'), 'Your ' . config('app.name') . ' validation code is ' . $phoneChangeCode->code);
        //$phoneChangeCode->notify(new VonageSMS('Your ' . config('app.name') . ' validation code is ' . $phoneChangeCode->code));
        Notification::send($phoneChangeCode, new VonageSMS('Your ' . config('app.name') . ' validation code is ' . $phoneChangeCode->code));
.....
.....

```

 ![register_by_phone](https://forum.ficusonline.com/uploads/default/original/2X/e/e7d35de99839061f9b4b1bbb810504b3b97ec8b5.jpeg)

 ![sms_validate_pin](https://forum.ficusonline.com/uploads/default/original/2X/0/0006c39d06b0c2e912919fc0a8892c7338441276.jpeg)

 ![vonage_received](https://forum.ficusonline.com/uploads/default/original/2X/5/5da9e9a7433fc44e80560d9ffcf2f6855a700464.jpeg)

---

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2023 年 8 月 23 日午前 10:50 UTC](https://forum.ficusonline.com/t/topic/479/18 "2023-08-23T10:50:32Z")

</div>

## Push Notification with the Session Initiation Protocol (SIP)

### Flexisip Push Notification Config

> **[Push notifications - XWiki](https://wiki.linphone.org/xwiki/wiki/public/view/Flexisip/Configuration/Push%20notifications/)**
>
> Push notifications

### Flexisip Push Notification Specification

> **[Push notifications - XWiki](https://wiki.linphone.org/xwiki/wiki/public/view/Flexisip/D.%20Specifications/Push%20notifications/)**
>
> Push notifications

> **[RFC 8599: Push Notification with the Session Initiation Protocol (SIP)](https://datatracker.ietf.org/doc/html/rfc8599)**
>
> This document describes how a Push Notification Service (PNS) can be used to wake a suspended Session Initiation Protocol (SIP) User Agent (UA) with push notifications, and it also describes how the UA can send binding-refresh REGISTER requests and...

---

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2023 年 8 月 24 日午前 4:50 UTC](https://forum.ficusonline.com/t/topic/479/19 "2023-08-24T04:50:41Z")

</div>

## Flexisip Account Manager フロントエンドデザイン更新

[https://github.com/BelledonneCommunications/flexisip-account-manager/tree/master](https://github.com/BelledonneCommunications/flexisip-account-manager/tree/master)

**ホーム画面**

 ![Screenshot from 2023-08-22 11-20-03](https://forum.ficusonline.com/uploads/default/original/2X/b/be97363b3f1392c39c6ddd819ab72aedd57f3622.png)

**ユーザ登録画面**

 ![Screenshot from 2023-08-22 11-20-24](https://forum.ficusonline.com/uploads/default/original/2X/f/f5c26618a578e93b60ce003bc0cde2fc02183b4c.png)

**メール認証画面**

 ![Screenshot from 2023-08-22 11-22-02](https://forum.ficusonline.com/uploads/default/original/2X/3/35e17934b1ab84fe8ab9066a91a4835563ad28f2.png)

**一般ユーザダッシュボード**

 ![Screenshot from 2023-08-22 11-22-25](https://forum.ficusonline.com/uploads/default/original/2X/d/d74b3b3ee8689671dc8d8e6da426d9f34907a469.png)

**管理者ダッシュボード**

 ![Screenshot from 2023-08-22 11-47-31-1](https://forum.ficusonline.com/uploads/default/original/2X/5/57afd3ce25ef42be26cdc4d612058bf38dbe1d93.png)

**管理者アカウント**

 ![Screenshot from 2023-08-22 11-48-23](https://forum.ficusonline.com/uploads/default/original/2X/0/04e1e8752487d556fe9dddd6ce481215930e19ee.png)

**登録ユーザ設定**

 ![sip.ficusonline.com_admin_accounts_3_edit(iPad Air)](https://forum.ficusonline.com/uploads/default/original/2X/b/bda99b6f6601c33012b4dd87e67dde08d419d373.jpeg)

---

<div class="post-metadata">

**Author:** ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)\
**Post date:** [2024 年 5 月 2 日午前 3:08 UTC](https://forum.ficusonline.com/t/topic/479/20 "2024-05-02T03:08:54Z")

</div>

アカウントマネージャのAPIでFirebaseによるプッシュ通知を利用する場合、アカウントマネージャを稼働しているphp-fpmコンテナ経由でflexisipサーバコンテナへコマンド送信する必要があるため、php-fpmコンテナにSSH接続などによる機能追加・PHPコードの変更などが必要になります。LaravelのフレームワークにSSHライブラリを追加することで対応できますがデバックなどに時間を要します。

このため、flexisipイメージにphp-fpmの機能を追加した新たなイメージを作成し、このイメージからflexisipサーバとphp-fpmを同時に立ち上げることにします。

> #### PHPとその機能拡張、Composerのインストールを追加

`flex-from-ubuntu-apt-repo`

```auto
FROM ubuntu:22.04
MAINTAINER Takanobu Fuse <ficusonline@gmail.com>

ARG DEBIAN_FRONTEND=noninteractive

# Prepare dependencies
RUN apt-get update
RUN apt-get install -y nano xsdcxx gdb libmariadb3 snmp-mibs-downloader snmp snmpd iproute2 iptables wget gnupg2 \ 
    php8.1-fpm libpng-dev libfreetype-dev libjpeg-turbo8-dev libxml2-dev curl zip unzip \
    php8.1-cli php8.1-common php8.1-mysql php8.1-zip php8.1-gd php8.1-mbstring php8.1-curl php8.1-xml php8.1-xmlrpc \
    php8.1-bcmath php8.1-redis
    
RUN echo 'deb [arch=amd64] http://linphone.org/snapshots/ubuntu jammy stable' > /etc/apt/sources.list.d/belledonne.list
RUN wget https://www.linphone.org/snapshots/ubuntu/pubkey.gpg -O - | apt-key add -
RUN apt-get update && apt-get install -y bc-flexisip

# Set working directory
WORKDIR /var/www/html

# Installing composer
COPY composer_installer.sh ./
RUN chmod +x composer_installer.sh
RUN echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf \
    && ./composer_installer.sh && mv composer.phar /usr/local/bin/composer
    
# Installing Laravel
RUN chown -R www-data:www-data /var/www/html
RUN composer global require laravel/installer \
    && ln -s /root/.config/composer/vendor/laravel/installer/bin/laravel /usr/local/bin/laravel
###### for fleisip-account-manager until the above line

# Add it to the default path
ENV PATH=$PATH:/opt/belledonne-communications/bin

WORKDIR /opt/belledonne-communications

# Generate a default configuration
RUN flexisip --dump-default all > /etc/flexisip/flexisip.conf

VOLUME /etc/opt/belledonne-communications/flexisip
VOLUME /var/opt/belledonne-communications/log/flexisip
COPY flexisip-entrypoint.sh /
COPY backtrace.gdb /
RUN chmod a+x /flexisip-entrypoint.sh

# Script to wait db before launch flexisip [Licence Apache2]
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.2.1/wait /wait
RUN chmod +x /wait

ENTRYPOINT ["/flexisip-entrypoint.sh"]
CMD flexisip

```

> #### 起動スクリプトにphp-fpmの起動コマンド`"/etc/init.d/php8.1-fpm start"`を追加

`flexisip-entrypoint.sh`

```auto
#!/bin/bash
ulimit -c unlimited
set -- flexisip "$@"

# Wait for needed container startup
/wait || exit $?

echo "Flexisip docker params : $*"

if [[$@ == *"--server"*]]; then
  echo "--server param found, starting only one Flexisip instance"
  "$@" &
else
  echo "Server param not found, starting 3 Flexisip instances (proxy, presence, conference)"
  ( "$@" --server proxy 2>&1| tee /var/opt/belledonne-communications/log/flexisip/flexisip_proxy_stdout.log ) &
  ( "$@" --server presence 2>&1| tee /var/opt/belledonne-communications/log/flexisip/flexisip_presence_stdout.log ) &
  ( "$@" --server conference 2>&1| tee /var/opt/belledonne-communications/log/flexisip/flexisip_conference_stdout.log ) &
fi

/etc/init.d/php8.1-fpm start

wait -n

echo "At least one server crashed, stopping every sub process that is still alive"
pkill -P $$

# coredump management, used in unit tests
# we execute gdb on each coredump, with the options given in backtrace.gdb file
# we search in /root because it's the workdir set in Dockerfile and because by default our coredumps are generated by default in the working directory
if [-n "$(find /root -type f -name "core*")"]; then
	find /root -type f -name "core*" | xargs -L1 gdb flexisip -x /backtrace.gdb;
fi

```

> #### Nginxのfastcgi\_passを変更

Dockerネットワークのゲートウェイアドレス：172.17.0.1などに変更

`default.conf`

```auto
    location = /index.php {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_keep_conn on;
        fastcgi_param HTTPS 'on';
        fastcgi_pass xx.xx.xx.xx:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

```

> #### PHP-FPM設定ファイル：接続方法の変更

ListenがデフォルトでUnixソケットなので、ポートに変更します。このファイルをコンテナ起動時に読み込ませるため、下記ディレクトリから抜き出してDocker Composeファイルで読み込むように設定して下さい。

`/etc/php/8.1/fpm/pool.d/www.conf`

```auto
.....
.....

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
; a specific port;
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 9000
.....
.....

```

コンテナ内でphp-fpmを再起動する場合

```auto
# service php8.1-fpm restart

```

> #### アカウントマネージャ.envの変更

php-fpmコンテナのネットワークをブリッジからホストへ変更したため、アカウントマネージャの.envファイル内で指定したサービス名によるホスト指定をIPアドレスによるものに変更します。

`flexiapi/.env`

```auto
.....
.....
DB_CONNECTION=mysql
DB_HOST=172.xx.xx.xx
.....
.....
REDIS_CLIENT=phpredis # Use phpredis-sentinel and uncomment the REDIS_SENTINEL variable bellow
REDIS_HOST=172.xx.xx.xx
.....
.....

```

* * *

注）ポート9000へのアクセスがufwによって制限されていると504エラーが発生します。  
Dockerの各ブリッジネットワークからのアクセスを許可します。

```auto
$ sudo ufw allow proto tcp from 172.16.0.0/12 

```

### Cloudflare:サーバ 521 エラー

[https://community.cloudflare.com/t/521-web-server-is-down-web/398712](https://community.cloudflare.com/t/521-web-server-is-down-web/398712)

注）nginxの設定で名前解決ができていない場合、521エラーが発生します。  
この場合、 **`docker-compose.yml`** の **nginx** セクションに **extra\_hosts** を追加して下さい。

```auto
##### nginx
  nginx:
    container_name: nginx
    image: nginx:alpine
    .....
    .....
    extra_hosts:
      - "sip.ficusonline.com:172.19.0.1"
    .....
    .....

```

原因はルートドメインのIPアドレスとサブドメインのIPアドレスが異なるため。CloudflareのプロキシーステータスをDNSのみとすること。

> [@Cloudflare: プロキシ機能、サーバセキュリティ、Certbot DNS-01チャレンジ、WARP Client](https://forum.ficusonline.com/t/topic/494/5):
>
> Intermittent 521 522 523 error [https://community.cloudflare.com/t/521-web-server-is-down-web/398712](https://community.cloudflare.com/t/521-web-server-is-down-web/398712)pingテスト HTTPS接続では、ポート443以外はキャッシュされないことが原因か？ HTTP ports supported by Cloudflare 80 8080 8880 2…

[次のページ](https://forum.ficusonline.com/t/topic/479.md?page=2)
