Ubuntu 20.04 linphone-sdk Docker Image >>> build linphone-desktop and flexisip

Flexisip Account Managerのデプロイ

flexisip-account-manager

題目の内容については別フォーラム記事でも何度か記載していますが、最新情報として改めて記載します。

flexisip-account-managerは以下2つの機能:プロビジョニングとウェブインターフェイスを含んでいます。

1.プロビジョニング

プロビジョニングとは、Linphoneアプリでサーバに登録済のユーザ情報を読み込む(書換え)ことであり、XML-RPCサーバでXMLフォーマットに変換されたユーザ情報が提供されます。conf, srcフォルダの中身がこの機能に関係します。

サンプルファイル
https://www.linphone.org/remote_provisioning.xml

confフォルダに格納された設定ファイルを以下 ページの

7. アカウントマネージャの設定
(データベースのテーブル作成phpコード tools/create_tables.php は既にありません。後述のLaravelのArtisanコンソールにより作成します。)

8. カスタム設定の読込(Provisioning)

を参照して変更して下さい。

2.ウェブインターフェイス

Laravel PHPフレームワークによるユーザ登録・管理用のウェブインターフェイスです。flexiapiフォルダがこれに該当します。

docker-composeファイルで定義したphp-fpm-laravelコンテナに入り、
flexiapiディレクトリ内で以下コマンドを実行します。

$ docker exec -ti php-fpm-laravel bash

# cd flexiapi
# composer install --no-dev
# cp .env.example .env
# php artisan key:generate

APP_KEYが追加された .envファイル でデータベースの設定などを行います。

APP_NAME=FlexiAPI
APP_ENV=local
APP_KEY=base64:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
APP_DEBUG=false
APP_URL=https://www.example.com
APP_SIP_DOMAIN=www.example.com
APP_FLEXISIP_PROXY_PID=/var/run/flexisip-proxy.pid
APP_FLEXISIP_PUSHER_PATH=
APP_EVERYONE_IS_ADMIN=false

# SIP server parameters
ACCOUNT_PROXY_REGISTRAR_ADDRESS=ficus-home.duckdns.org # Proxy registrar address, can be different than the SIP domain
ACCOUNT_TRANSPORT_PROTOCOL_TEXT="TLS (recommended), TCP or UDP" # Simple text, to explain how the SIP server can be reached
ACCOUNT_REALM=null # Default realm for the accounts, fallback to the domain if not set, enforce null by default

# Account provisioning
ACCOUNT_PROVISIONING_RC_FILE=
ACCOUNT_PROVISIONING_OVERWRITE_ALL=

# Instance specific parameters
INSTANCE_COPYRIGHT= # Simple text displayed in the page footer
INSTANCE_INTRO_REGISTRATION= # Markdown text displayed in the home page
INSTANCE_CUSTOM_THEME=false
INSTANCE_CONFIRMED_REGISTRATION_TEXT= # Markdown text displayed when an account is confirmed

NEWSLETTER_REGISTRATION_ADDRESS= # Address to contact when a user wants to register to the newsletter
PUBLIC_REGISTRATION=true # Toggle to enable/disable the public registration forms
PHONE_AUTHENTICATION=true # Toggle to enable/disable the SMS support, requires public registration
DEVICES_MANAGEMENT=false # Toggle to enable/disable the devices management support

TERMS_OF_USE_URL= # A URL pointing to the Terms of Use
PRIVACY_POLICY_URL= # A URL pointing to the Privacy Policy

LOG_CHANNEL=stack

# External FlexiSIP database
# Ensure that you have the proper SELinux configuration to allow database connections, see the README
DB_DRIVER=mysql
DB_HOST=database_host
DB_PORT=3306
DB_DATABASE=flexisip
DB_USERNAME=flexisip
DB_PASSWORD=password

# Logs
# Ensure that you have the proper SELinux configuration to write in the storage directory, see the README
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=cookie
SESSION_LIFETIME=120

# SMTP and emails
# Ensure that you have the proper SELinux configuration to allow emails sending, see the README
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=xxxxxxxxxxxxxxxxxx
MAIL_PASSWORD=xxxxxxxxxxxxxxxxxx
MAIL_ENCRYPTION=tls
[email protected]
MAIL_FROM_NAME=xxxxxxxxxxxx
MAIL_ALLOW_SELF_SIGNED=false
MAIL_VERIFY_PEER=true
MAIL_VERIFY_PEER_NAME=true
MAIL_SIGNATURE="The xxxxx Team"
MAIL_ENCRYPTION=tls

# OVH SMS API variables
OVH_APP_KEY=
OVH_APP_SECRET=
OVH_APP_ENDPOINT=ovh-eu
OVH_APP_CONSUMER_KEY=
OVH_APP_SENDER=

# Google reCaptcha v2 parameters
NOCAPTCHA_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
NOCAPTCHA_SITEKEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Flexisipに必要なテーブルを作成します。事前にphpからmysqlへ接続するドライバ拡張モジュール pdo_mysql をインストールします(これはphp-fpmイメージ作成時にインストールするようDockerfileに事前に記述しておきましょう)。
https://www.php.net/manual/en/ref.pdo-mysql.php

# docker-php-ext-install pdo_mysql

LaravelのArtisanコンソールによりテーブルを作成します。

# php artisan migrate

.envファイルで設定したURLにアクセスすると以下ページが表示されます。
なお、ユーザ登録を有効にするには、.envファイルの SMTP and emails(email認証する場合)OVH SMS API variables(SMS認証する場合) セクションの設定とreCAPTCHAの設定が必要です。

アカウント作成・管理ホーム画面

Email認証によるユーザ登録画面

注)500サーバエラーが表示された場合、flexiapiのアクセス権を見直すか、コンテナを再起動して下さい。

管理者ユーザの設定

登録した任意のユーザを管理者ユーザに設定します。
php-fpm-laravelコンテナ内で以下のLaravelphp artisan コマンドにより既存ユーザを管理者登録します。登録ユーザのIDを指定します。

$ dcoker exec -ti php-fpm-laravel bash
# php artisan accounts:set-admin USER_ID_NUMBER

php artisan ヘルプ

# php artisan --help

php artisan “accounts:set-admin” ヘルプ

# php artisan accounts:set-admin --help
Description:
  Give the admin role to an account

Usage:
  accounts:set-admin <id>

Arguments:
  id                    

管理者ユーザになることにより、他ユーザアカウントの管理・追加・編集権限が付与されます。

管理メニュー

ユーザアカウントリスト

ユーザアカウント

テーマのカスタマイズ

Custom theme

If you set INSTANCE_CUSTOM_THEME to true, FlexiAPI will try to load a CSS file located in public/css/$APP_ENV.style.css. If the file doesn’t exists it will fallback to public/css/style.css.

We advise you to copy the style.css file and rename it to make your custom CSS configurations for your instance.