Lime Server 公式リリース
LIMEサーバのダウンロード
https://gitlab.linphone.org/BC/public/lime-server/-/tree/release/1.3?ref_type=heads
最新版バージョン1.3のダウンロード
$ git clone -b release/1.3 https://gitlab.linphone.org/BC/public/lime-server.git
PHPファイルの配置
docker-composeによって稼働しているシステムにLIMEサーバ用PHPファイルを組入れます。ダウンロードした src フォルダの中身を、下記の構成で配置して下さい。
lime-server
フォルダはdocker-compose.yml
が保存されているディレクトリ内に配置します。
ログファイルは新規の空ファイル(各ファイル名とパスはlime-server.conf
で設定)を作成して下さい。
$ tree lime-server
lime-server
├── lime-server.conf
├── log
│ └── lime-server
│ ├── access-lime.log
│ ├── lime-db.log
│ └── lime.log
└── lime
├── authenticated_lime.php
├── lime-createBase.php
├── lime-server.php
└── lime.php
LIMEサーバ設定ファイル
LIMEサーバの設定ファイルlime-server.conf
でLIMEで使用する暗号化楕円曲線、データベース、レルム、ダイジェスト認証の有無などを設定します。
主な設定箇所は以下の通りです。必要に応じて他のパラメータも指定・変更して下さい。
lime-server.conf
// Curve(s) to use, shall be either CurveId::CURVE25519, CurveId::CURVE448 or CURVE25519K512
// to allow only one base algorithm on the server, you can use the curveId and LIME_DB_NAME defines as a shortcut or legacy mode
define ("curveId", CurveId::CURVE25519);
define("LIME_DB_NAME", "databese");
// Flexisip database access for authentication
define("AUTH_DB_HOST", "xx.xx.xx.xx");
define("AUTH_DB_USER", "user");
define("AUTH_DB_PASSWORD", "password");
define("AUTH_DB_NAME", "database");
// Lime database access
// this database must already exists with the requested tables
define("LIME_DB_HOST", "xx.xx.xx.xx");
define("LIME_DB_USER", "user");
define("LIME_DB_PASSWORD", "password");
// Allow user db authentication
// explicitely define this constant to false is the only way to disable the digest auth
// if this constant is not defined, digest auth is enabled by default
define("DIGEST_AUTH", true);
// Authentication realm
// If this is not defined, the realm is fetched from the request. Do it ONLY if you need to run several domain/realms on one lime server.
// Otherwise this should be defined to your domain.
define("AUTH_REALM", "sip.example.com");
Nginx設定ファイルの追加
NginxコンテナでWEBサーバを稼働しているため、LIMEサーバ用設定ファイルを追加します(サブドメインhttps://lime.example.com
でアクセス)。
nginx/lime.conf
server {
server_name lime.example.com;
server_tokens off;
index lime-server.php;
access_log /var/log/nginx/lime.access.log;
error_log /var/log/nginx/lime.error.log error;
root /var/www/html/lime;
location ~ \.php$ {
try_files $uri =404;
# fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_pass xx.xx.xx.xx:9000;
# fastcgi_index lime-server.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_connect_timeout 1800;
send_timeout 3000;
fastcgi_read_timeout 3000;
}
listen [::]:443 ssl;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
docker-composeファイルの編集
docker-compose.yml
のnginxとubuntu-flexisipの各サービスのvolumesセクションで、lime-server
ディレクトリ(ファイル)をコンテナ内の適切なディレクトリ(ファイル)にマウントします。
docker-compose-yml
.....
.....
##### nginx
nginx:
container_name: nginx
image: nginx:alpine
tty: true
ports:
- 80:80
- 443:443
volumes:
......
......
### official lime
- ./lime-server/lime:/var/www/html/lime
.....
.....
### flexisip
ubuntu-flexisip:
container_name: ubuntu-flexisip
build:
context: ./docker_files
dockerfile: flex-from-ubuntu-apt-repo
volumes:
......
......
### official lime server
- ./lime-server/lime:/var/www/html/lime
- ./lime-server/lime-server.conf:/etc/lime-server/lime-server.conf
- ./lime-server/log/lime-server:/var/opt/belledonne-communications/log/lime-server
......
......
LIME専用テーブルの作成
既存のデータベース内にLIME専用テーブルを新規に作成します。
docker compose コマンドでシステムを起動後、LIME専用のテーブルを以下のSQLクエリで作成します。
START TRANSACTION;
CREATE TABLE IF NOT EXISTS `Users` (
`Uid` INTEGER NOT NULL AUTO_INCREMENT,
`UserId` TEXT COLLATE utf8_bin NOT NULL,
`Ik` BLOB NOT NULL,
`SPk` BLOB DEFAULT NULL,
`SPk_sig` BLOB DEFAULT NULL,
`SPk_id` INTEGER UNSIGNED DEFAULT NULL,
PRIMARY KEY(`Uid`),
INDEX(UserId(100))
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE IF NOT EXISTS `OPk` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`Uid` INTEGER NOT NULL,
`OPk` BLOB NOT NULL,
`OPk_id` INTEGER UNSIGNED NOT NULL,
PRIMARY KEY(`id`),
FOREIGN KEY(`Uid`) REFERENCES Users(`Uid`) ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE IF NOT EXISTS Requests (
`source` TEXT NOT NULL,
`target` TEXT NOT NULL,
`at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE IF NOT EXISTS `Config` (
`Name` VARCHAR(20) COLLATE utf8_bin DEFAULT NULL,
`Value` INTEGER NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
INSERT INTO `Config` (`Name`, `Value`) VALUES
('version', 1);
CREATE EVENT clean_requests ON SCHEDULE EVERY 1 WEEK DO
DELETE FROM Requests WHERE at < DATE_SUB(NOW(), INTERVAL 2 WEEK);
COMMIT;
上記SQLクエリでイベントスケジューラを設定していますが、MySQLではデフォルトでイベントスケジューラが無効になっているようなので、これを有効にします。
SET GLOBAL event_scheduler = ON;
イベントスケジューラが有効かどうかの確認は、
SHOW VARIABLES LIKE 'event_scheduler';
event_scheduler ON
MariaDBコンテナでイベントスケジューラを恒久的にONにする場合、docker-compose.ymlのMariaDBサービスにcommandオプションを追加して下さい。
command: --event-scheduler=ON
ログ管理(オプション)
ホストのlogrotateデーモンを、lime-serverのログファイルに適用します。
ホストマシン上で設定ファイルを作成。
注) ログファイルのディレクトリはdocker-compose.yml
でマウント(共有)済です。
/etc/logrotate.d/docker_lime
/project_pass_including_docker-compose.yml/lime-server/log/lime-server/access-lime*.log {
maxsize 50M
dateext dateformat -%Y%m%d%H
create
daily
rotate 7
missingok
notifempty
delaycompress
}
/project_pass_including_docker-compose.yml/lime-server/log/lime-server/lime*.log {
maxsize 50M
dateext dateformat -%Y%m%d%H
create
daily
rotate 7
missingok
notifempty
delaycompress
}